diff --git a/src/editor_hard.cpp b/src/editor_hard.cpp index c58903c..a32c57f 100644 --- a/src/editor_hard.cpp +++ b/src/editor_hard.cpp @@ -1,23 +1,23 @@ -#include +#include "strings.h" #include #include +#include #include #include #include #include #include -#include "strings.h" using nlohmann::json; -void save_document(std::string& text, std::vector& lines) { +void save_document(std::string &text, std::vector &lines) { text = ""; - for (const std::string& line : lines) { + for (const std::string &line : lines) { text.append(line); text.append("\n"); } } -void editor_hard(std::string& text) { +void editor_hard(std::string &text) { uint16_t cursor_x = 0; uint16_t cursor_y = 0; std::vector lines; @@ -48,7 +48,8 @@ void editor_hard(std::string& text) { while (true) { clear(); // Draw text lines - for (size_t i = 0; i < window_height - 1 && i < lines.size(); i++) { + for (size_t i = 0; + i < static_cast(window_height) - 1 && i < lines.size(); i++) { mvprintw(i, 0, "%s", lines[i].c_str()); } @@ -61,128 +62,128 @@ void editor_hard(std::string& text) { { int ch = getch(); switch (mode) { - case 'n': // Normal mode - switch (ch) { - case 'h': - if (cursor_x > 0) { - cursor_x--; - } - break; - case 'j': - if (cursor_y < lines.size() - 1) { - cursor_y++; - if (cursor_x > lines[cursor_y].length()) { - cursor_x = lines[cursor_y].length(); - } - } - break; - case 'k': - if (cursor_y > 0) { - cursor_y--; - if (cursor_x > lines[cursor_y].length()) { - cursor_x = lines[cursor_y].length(); - } - } - - break; - case 'l': - if (cursor_x < lines[cursor_y].length()) { - cursor_x++; - } - break; - case 'i': - case 'a': - mode = 'i'; - break; - case 'x': - if (cursor_x < lines[cursor_y].length()) { - lines[cursor_y].erase(cursor_x, 1); - } - break; - case ':': { - // Enter command mode - std::string command = ""; - int cmd_ch; - // Show command prompt - mvprintw(window_height - 1, 0, ":%s", command.c_str()); - clrtoeol(); - refresh(); - - while ((cmd_ch = getch()) != '\n' && cmd_ch != '\r') { - if (cmd_ch == 27) { // ESC - cancel command - break; - } else if (cmd_ch == KEY_BACKSPACE || cmd_ch == 127) { - if (!command.empty()) { - command.pop_back(); - } - } else if (cmd_ch >= 32 && cmd_ch <= 126) { - command += static_cast(cmd_ch); - } - - mvprintw(window_height - 1, 0, ":%s", command.c_str()); - clrtoeol(); - refresh(); - } - - // Execute command - if (cmd_ch != 27) { // If not cancelled - switch (hash_djb2a(command)) { - case "q"_sh: - return; - break; - case "w"_sh: - save_document(text, lines); - break; - - case "wq"_sh: - case "x"_sh: - save_document(text, lines); - return; - break; - - case "q!"_sh: - return; - break; - } - } - } break; + case 'n': // Normal mode + switch (ch) { + case 'h': + if (cursor_x > 0) { + cursor_x--; } break; + case 'j': + if (cursor_y < lines.size() - 1) { + cursor_y++; + if (cursor_x > lines[cursor_y].length()) { + cursor_x = lines[cursor_y].length(); + } + } + break; + case 'k': + if (cursor_y > 0) { + cursor_y--; + if (cursor_x > lines[cursor_y].length()) { + cursor_x = lines[cursor_y].length(); + } + } - case 'i': // Insert mode - switch (ch) { - case 27: // ESC - mode = 'n'; - if (cursor_x > 0) - cursor_x--; + break; + case 'l': + if (cursor_x < lines[cursor_y].length()) { + cursor_x++; + } + break; + case 'i': + case 'a': + mode = 'i'; + break; + case 'x': + if (cursor_x < lines[cursor_y].length()) { + lines[cursor_y].erase(cursor_x, 1); + } + break; + case ':': { + // Enter command mode + std::string command = ""; + int cmd_ch; + // Show command prompt + mvprintw(window_height - 1, 0, ":%s", command.c_str()); + clrtoeol(); + refresh(); + + while ((cmd_ch = getch()) != '\n' && cmd_ch != '\r') { + if (cmd_ch == 27) { // ESC - cancel command break; - case KEY_BACKSPACE: - case 127: - if (mode == 'i' && cursor_x > 0) { - lines[cursor_y].erase(cursor_x - 1, 1); - cursor_x--; + } else if (cmd_ch == KEY_BACKSPACE || cmd_ch == 127) { + if (!command.empty()) { + command.pop_back(); } + } else if (cmd_ch >= 32 && cmd_ch <= 126) { + command += static_cast(cmd_ch); + } + + mvprintw(window_height - 1, 0, ":%s", command.c_str()); + clrtoeol(); + refresh(); + } + + // Execute command + if (cmd_ch != 27) { // If not cancelled + switch (hash_djb2a(command)) { + case "q"_sh: + return; break; - case '\n': - case '\r': { - // Insert new line - std::string new_line = lines[cursor_y].substr(cursor_x); - lines[cursor_y] = lines[cursor_y].substr(0, cursor_x); - lines.insert(lines.begin() + cursor_y + 1, new_line); - cursor_y++; - cursor_x = 0; + case "w"_sh: + save_document(text, lines); + break; + + case "wq"_sh: + case "x"_sh: + save_document(text, lines); + return; + break; + + case "q!"_sh: + return; break; } - default: - if (ch >= 32 && ch <= 126) { - if (mode == 'i') { - lines[cursor_y].insert(cursor_x, 1, ch); - cursor_x++; - } - } - break; + } + } break; + } + break; + + case 'i': // Insert mode + switch (ch) { + case 27: // ESC + mode = 'n'; + if (cursor_x > 0) + cursor_x--; + break; + case KEY_BACKSPACE: + case 127: + if (mode == 'i' && cursor_x > 0) { + lines[cursor_y].erase(cursor_x - 1, 1); + cursor_x--; } break; + case '\n': + case '\r': { + // Insert new line + std::string new_line = lines[cursor_y].substr(cursor_x); + lines[cursor_y] = lines[cursor_y].substr(0, cursor_x); + lines.insert(lines.begin() + cursor_y + 1, new_line); + cursor_y++; + cursor_x = 0; + break; + } + default: + if (ch >= 32 && ch <= 126) { + if (mode == 'i') { + lines[cursor_y].insert(cursor_x, 1, ch); + cursor_x++; + } + } + break; + } + break; } } } diff --git a/src/menu.cpp b/src/menu.cpp index b4799e3..d6c92c0 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -1,19 +1,3 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include "color.h" #include "const.h" #include "cups.h" @@ -24,13 +8,31 @@ #include "signal.h" #include "strings.h" #include "types.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include using nlohmann::json; std::vector main_menu_allocated; #define COMPLAINTS_DIR "complaints" -std::array get_name_date_from_item(ITEM* item) { +std::array get_name_date_from_item(ITEM *item) { std::stringstream ss(item_description(item)); std::array name_date; name_date[0] = item_name(item); @@ -38,7 +40,7 @@ std::array get_name_date_from_item(ITEM* item) { return name_date; } -void reload_menu_from_directory(complete_menu& main_menu) { +void reload_menu_from_directory(complete_menu &main_menu) { // Clean up existing menu items and allocated memory if (main_menu.menu != nullptr) { unpost_menu(main_menu.menu); @@ -61,7 +63,7 @@ void reload_menu_from_directory(complete_menu& main_menu) { for (auto it = main_menu_allocated.begin(); it != main_menu_allocated.end();) { if (it->type == GENERIC_TYPE) { - delete[] static_cast(it->ptr); + delete[] static_cast(it->ptr); it = main_menu_allocated.erase(it); } else { ++it; @@ -69,10 +71,10 @@ void reload_menu_from_directory(complete_menu& main_menu) { } // Recreate items from directory (same logic as initialization) - std::vector items; + std::vector items; if (std::filesystem::exists(COMPLAINTS_DIR)) { - for (const std::filesystem::directory_entry& directroy_entry : + for (const std::filesystem::directory_entry &directroy_entry : std::filesystem::directory_iterator(COMPLAINTS_DIR)) { if (directroy_entry.is_regular_file()) { std::ifstream file(directroy_entry.path()); @@ -96,9 +98,9 @@ void reload_menu_from_directory(complete_menu& main_menu) { loc_strings ->status_strings[complaint_json["status"].get()]); - char* name = new char[name_date[0].length() + 1]; + char *name = new char[name_date[0].length() + 1]; main_menu_allocated.push_back({GENERIC_TYPE, name, 1}); - char* date = new char[name_date[1].length() + 1]; + char *date = new char[name_date[1].length() + 1]; main_menu_allocated.push_back({GENERIC_TYPE, date, 1}); strcpy(name, name_date[0].c_str()); @@ -112,9 +114,9 @@ void reload_menu_from_directory(complete_menu& main_menu) { items.push_back(nullptr); // Create new menu items array - main_menu.items = new ITEM*[items.size()]; + main_menu.items = new ITEM *[items.size()]; main_menu.items_size = items.size() - 1; - memcpy(main_menu.items, items.data(), (items.size() * sizeof(ITEM*))); + memcpy(main_menu.items, items.data(), (items.size() * sizeof(ITEM *))); // Create new menu main_menu.menu = new_menu(main_menu.items); @@ -138,7 +140,7 @@ void menu() { start_color(); cbreak(); noecho(); - curs_set(0); // Makes cursor invisible + curs_set(0); // Makes cursor invisible keypad(stdscr, TRUE); for (uint8_t i = 0; i < 8; i++) { init_pair(i, i, COLOR_BLACK); @@ -149,9 +151,9 @@ void menu() { complete_menu main_menu = {nullptr, nullptr, 0, nullptr}; main_menu_allocated.push_back({COMPLETE_MENU_TYPE, &main_menu, 1}); { - std::vector items; + std::vector items; if (std::filesystem::exists(COMPLAINTS_DIR)) { - for (const std::filesystem::directory_entry& directroy_entry : + for (const std::filesystem::directory_entry &directroy_entry : std::filesystem::directory_iterator(COMPLAINTS_DIR)) { if (directroy_entry.is_regular_file()) { std::ifstream file(directroy_entry.path()); @@ -173,9 +175,9 @@ void menu() { loc_strings ->status_strings[complaint_json["status"].get()]); - char* name = new char[name_date[0].length() + 1]; + char *name = new char[name_date[0].length() + 1]; main_menu_allocated.push_back({GENERIC_TYPE, name, 1}); - char* date = new char[name_date[1].length() + 1]; + char *date = new char[name_date[1].length() + 1]; main_menu_allocated.push_back({GENERIC_TYPE, date, 1}); strcpy(name, name_date[0].c_str()); strcpy(date, name_date[1].c_str()); @@ -186,9 +188,9 @@ void menu() { std::filesystem::create_directory(COMPLAINTS_DIR); } items.push_back(nullptr); - main_menu.items = new ITEM*[items.size()]; + main_menu.items = new ITEM *[items.size()]; main_menu.items_size = items.size() - 1; - memcpy(main_menu.items, items.data(), (items.size() * sizeof(ITEM*))); + memcpy(main_menu.items, items.data(), (items.size() * sizeof(ITEM *))); } /* Crate menu */ @@ -222,204 +224,205 @@ void menu() { int c; while ((c = wgetch(main_menu.win)) != KEY_F(1)) { switch (c) { - case KEY_DOWN: - menu_driver(main_menu.menu, REQ_DOWN_ITEM); - break; - case KEY_UP: - menu_driver(main_menu.menu, REQ_UP_ITEM); - break; - case 10: + case KEY_DOWN: + menu_driver(main_menu.menu, REQ_DOWN_ITEM); + break; + case KEY_UP: + menu_driver(main_menu.menu, REQ_UP_ITEM); + break; + case 10: - refresh(); - break; - case ':': - switch (hash_djb2a(spawncmd())) { - case "print"_sh: - case "p"_sh: { - // DONT FORGET TO PRINT ACTUAL DOCUMENT - std::array name_date = - get_name_date_from_item(current_item(main_menu.menu)); - std::ifstream selected_file(COMPLAINTS_DIR "/" + name_date[0] + - '_' + name_date[1]); - if (!selected_file.is_open()) { - std::clog << selected_file.rdstate() << "\n"; - std::cerr << RED "[ERROR] " RESET << loc_strings->invalid_input - << "\n" - << "File: " - << COMPLAINTS_DIR "/" + name_date[0] + '_' + - name_date[1] - << "\n"; - exit(EINVAL); - } - - json selected_file_json = json::parse(selected_file); - - printDocument( - selected_file_json["complaint_text"].get()); - current_allocated = &main_menu_allocated; - break; - } - case "easy_edit"_sh: - case "ee"_sh: { - const std::string name = spawncmd(loc_strings->reference_name); - if (name == "") { - print_in_middle(main_menu.win, 10, 0, 40, - loc_strings->invalid_input, COLOR_PAIR(1)); - } - - const time_t current_time = time(nullptr); - const tm* local_time = localtime(¤t_time); - - char formatted_date[11]; - strftime(formatted_date, sizeof(formatted_date), "%d-%m-%Y", - local_time); - - std::ofstream complaint_file(COMPLAINTS_DIR "/" + name + "_" + - formatted_date); - - const std::string complaint_text = vytvorTrestniOznameni(); - - json complaint_json = {{"date", formatted_date}, - {"status", NOT_SEND}, - {"complaint_text", complaint_text}}; - - complaint_file << complaint_json; - complaint_file.close(); - current_allocated = &main_menu_allocated; - reload_menu_from_directory(main_menu); - break; - } - case "eh"_sh: { - std::array name_date = - get_name_date_from_item(current_item(main_menu.menu)); - std::ifstream selected_file(COMPLAINTS_DIR "/" + name_date[0] + - '_' + name_date[1]); - if (!selected_file.is_open()) { - std::clog << selected_file.rdstate() << "\n"; - std::cerr << RED "[ERROR] " RESET << loc_strings->invalid_input - << "\n" - << "File: " - << COMPLAINTS_DIR "/" + name_date[0] + '_' + - name_date[1] - << "\n"; - exit(EINVAL); - } - - json selected_file_json = json::parse(selected_file); - selected_file.close(); - std::string complaint_text = - selected_file_json["complaint_text"].get(); - editor_hard(complaint_text); - curs_set(0); - clear(); - selected_file_json["complaint_text"] = complaint_text; - std::ofstream selected_file_out(COMPLAINTS_DIR "/" + name_date[0] + - '_' + name_date[1]); - selected_file_out << selected_file_json; - selected_file_out.close(); - - break; - } - default: - print_in_middle(main_menu.win, 10, 0, 40, - loc_strings->unknown_command, COLOR_PAIR(1)); - break; - } - break; - case 'm': { - int current_item_index = item_index(current_item(main_menu.menu)); + refresh(); + break; + case ':': + switch (hash_djb2a(spawncmd())) { + case "print"_sh: + case "p"_sh: { + // DONT FORGET TO PRINT ACTUAL DOCUMENT std::array name_date = get_name_date_from_item(current_item(main_menu.menu)); - - { - uint8_t n = 0; - size_t indexes[2]; - for (size_t i = 0; (i < main_menu_allocated.size()); i++) { - if (main_menu_allocated[i].ptr == - item_name(current_item(main_menu.menu))) { - delete[] static_cast(main_menu_allocated[i].ptr); - indexes[0] = i; - n++; - } else if (main_menu_allocated[i].ptr == - item_description(current_item(main_menu.menu))) { - delete[] static_cast(main_menu_allocated[i].ptr); - indexes[1] = i; - n++; - } - if (n >= 2) { - break; - } - } - if (indexes[0] > indexes[1]) { - std::swap(indexes[0], indexes[1]); - } - main_menu_allocated.erase(main_menu_allocated.begin() + indexes[1]); - main_menu_allocated.erase(main_menu_allocated.begin() + indexes[0]); + std::ifstream selected_file(COMPLAINTS_DIR "/" + name_date[0] + '_' + + name_date[1]); + if (!selected_file.is_open()) { + std::clog << selected_file.rdstate() << "\n"; + std::cerr << RED "[ERROR] " RESET << loc_strings->invalid_input + << "\n" + << "File: " + << COMPLAINTS_DIR "/" + name_date[0] + '_' + name_date[1] + << "\n"; + exit(EINVAL); } - { - std::ifstream selected_file(COMPLAINTS_DIR "/" + name_date[0] + '_' + - name_date[1]); - if (!selected_file.is_open()) { - std::clog << selected_file.rdstate() << "\n"; - std::cerr << RED "[ERROR] " RESET << loc_strings->invalid_input - << "\n" - << "File: " - << COMPLAINTS_DIR "/" + name_date[0] + '_' + name_date[1] - << "\n"; - exit(EINVAL); - } - json selected_file_json = json::parse(selected_file); - selected_file.close(); - if (selected_file_json["status"].is_null() || - selected_file_json["status"].get() < STATUS_COUNT) { - (selected_file_json["status"].get() + 1 >= STATUS_COUNT) - ? selected_file_json["status"] = NOT_SEND - : selected_file_json["status"] = - selected_file_json["status"].get() + 1; + json selected_file_json = json::parse(selected_file); - std::ofstream selected_file(COMPLAINTS_DIR "/" + name_date[0] + - '_' + name_date[1]); - selected_file << selected_file_json; - selected_file.close(); - } else { - std::cerr << RED "[ERROR] " RESET << loc_strings->invalid_input - << "\n"; - exit(EINVAL); - } - - name_date[1].append(" "); - name_date[1].append( - loc_strings->status_strings[selected_file_json["status"] - .get()]); - char* date_status = new char[name_date[1].length() + 1]; - main_menu_allocated.push_back({GENERIC_TYPE, date_status, 1}); - strlcpy(date_status, name_date[1].c_str(), name_date[1].length() + 1); - - char* name = new char[name_date[0].length() + 1]; - main_menu_allocated.push_back({GENERIC_TYPE, name, 1}); - strlcpy(name, name_date[0].c_str(), name_date[0].length() + 1); - - for (size_t i = 0; i < main_menu.items_size; i++) { - if (main_menu.items[i] == current_item(main_menu.menu)) { - free_item(main_menu.items[i]); - main_menu.items[i] = new_item(name, date_status); - break; - } - } - } - WINDOW* old_win_sub = menu_sub(main_menu.menu); - unpost_menu(main_menu.menu); - free_menu(main_menu.menu); - main_menu.menu = new_menu(main_menu.items); - set_menu_win(main_menu.menu, main_menu.win); - set_menu_sub(main_menu.menu, old_win_sub); - set_menu_format(main_menu.menu, 7, 1); - set_menu_mark(main_menu.menu, " * "); - set_current_item(main_menu.menu, main_menu.items[current_item_index]); - post_menu(main_menu.menu); + printDocument(selected_file_json["complaint_text"].get()); + current_allocated = &main_menu_allocated; break; } + case "easy_edit"_sh: + case "ee"_sh: { + const std::string name = spawncmd(loc_strings->reference_name); + if (name == "") { + print_in_middle(main_menu.win, 10, 0, 40, loc_strings->invalid_input, + COLOR_PAIR(1)); + } + + const time_t current_time = time(nullptr); + const tm *local_time = localtime(¤t_time); + + char formatted_date[11]; + strftime(formatted_date, sizeof(formatted_date), "%d-%m-%Y", + local_time); + + std::ofstream complaint_file(COMPLAINTS_DIR "/" + name + "_" + + formatted_date); + + const std::string complaint_text = vytvorTrestniOznameni(); + + json complaint_json = {{"date", formatted_date}, + {"status", NOT_SEND}, + {"complaint_text", complaint_text}}; + + complaint_file << complaint_json; + complaint_file.close(); + current_allocated = &main_menu_allocated; + reload_menu_from_directory(main_menu); + break; + } + case "eh"_sh: { + std::array name_date = + get_name_date_from_item(current_item(main_menu.menu)); + std::ifstream selected_file(COMPLAINTS_DIR "/" + name_date[0] + '_' + + name_date[1]); + if (!selected_file.is_open()) { + std::clog << selected_file.rdstate() << "\n"; + std::cerr << RED "[ERROR] " RESET << loc_strings->invalid_input + << "\n" + << "File: " + << COMPLAINTS_DIR "/" + name_date[0] + '_' + name_date[1] + << "\n"; + exit(EINVAL); + } + + json selected_file_json = json::parse(selected_file); + selected_file.close(); + std::string complaint_text = + selected_file_json["complaint_text"].get(); + editor_hard(complaint_text); + curs_set(0); + clear(); + selected_file_json["complaint_text"] = complaint_text; + std::ofstream selected_file_out(COMPLAINTS_DIR "/" + name_date[0] + + '_' + name_date[1]); + selected_file_out << selected_file_json; + selected_file_out.close(); + + break; + } + default: + print_in_middle(main_menu.win, 10, 0, 40, loc_strings->unknown_command, + COLOR_PAIR(1)); + break; + } + break; + case 'm': { + int current_item_index = item_index(current_item(main_menu.menu)); + std::array name_date = + get_name_date_from_item(current_item(main_menu.menu)); + + { + uint8_t n = 0; + size_t indexes[2] = {ULONG_MAX, ULONG_MAX}; // fix compiler warning + for (size_t i = 0; (i < main_menu_allocated.size()); i++) { + if (main_menu_allocated[i].ptr == + item_name(current_item(main_menu.menu))) { + delete[] static_cast(main_menu_allocated[i].ptr); + indexes[0] = i; + n++; + } else if (main_menu_allocated[i].ptr == + item_description(current_item(main_menu.menu))) { + delete[] static_cast(main_menu_allocated[i].ptr); + indexes[1] = i; + n++; + } + if (n >= 2) { + break; + } + } + if (indexes[0] == ULONG_MAX || indexes[1] == ULONG_MAX) { + std::cerr << RED "[ERROR]" << RESET " HOW DID THIS EVEN HAPPEN\n"; + safe_exit(84); + } + if (indexes[0] > indexes[1]) { + std::swap(indexes[0], indexes[1]); + } + main_menu_allocated.erase(main_menu_allocated.begin() + indexes[1]); + main_menu_allocated.erase(main_menu_allocated.begin() + indexes[0]); + } + { + std::ifstream selected_file(COMPLAINTS_DIR "/" + name_date[0] + '_' + + name_date[1]); + if (!selected_file.is_open()) { + std::clog << selected_file.rdstate() << "\n"; + std::cerr << RED "[ERROR] " RESET << loc_strings->invalid_input + << "\n" + << "File: " + << COMPLAINTS_DIR "/" + name_date[0] + '_' + name_date[1] + << "\n"; + exit(EINVAL); + } + json selected_file_json = json::parse(selected_file); + selected_file.close(); + if (selected_file_json["status"].is_null() || + selected_file_json["status"].get() < STATUS_COUNT) { + + (selected_file_json["status"].get() + 1 >= STATUS_COUNT) + ? selected_file_json["status"] = NOT_SEND + : selected_file_json["status"] = + selected_file_json["status"].get() + 1; + + std::ofstream selected_file(COMPLAINTS_DIR "/" + name_date[0] + '_' + + name_date[1]); + selected_file << selected_file_json; + selected_file.close(); + } else { + std::cerr << RED "[ERROR] " RESET << loc_strings->invalid_input + << "\n"; + exit(EINVAL); + } + + name_date[1].append(" "); + name_date[1].append( + loc_strings + ->status_strings[selected_file_json["status"].get()]); + char *date_status = new char[name_date[1].length() + 1]; + main_menu_allocated.push_back({GENERIC_TYPE, date_status, 1}); + strlcpy(date_status, name_date[1].c_str(), name_date[1].length() + 1); + + char *name = new char[name_date[0].length() + 1]; + main_menu_allocated.push_back({GENERIC_TYPE, name, 1}); + strlcpy(name, name_date[0].c_str(), name_date[0].length() + 1); + + for (size_t i = 0; i < main_menu.items_size; i++) { + if (main_menu.items[i] == current_item(main_menu.menu)) { + free_item(main_menu.items[i]); + main_menu.items[i] = new_item(name, date_status); + break; + } + } + } + WINDOW *old_win_sub = menu_sub(main_menu.menu); + unpost_menu(main_menu.menu); + free_menu(main_menu.menu); + main_menu.menu = new_menu(main_menu.items); + set_menu_win(main_menu.menu, main_menu.win); + set_menu_sub(main_menu.menu, old_win_sub); + set_menu_format(main_menu.menu, 7, 1); + set_menu_mark(main_menu.menu, " * "); + set_current_item(main_menu.menu, main_menu.items[current_item_index]); + post_menu(main_menu.menu); + break; + } } wrefresh(main_menu.win); refresh();