fix templates
Some checks failed
build_test / build (push) Failing after 3m32s

This commit is contained in:
PoliEcho 2025-05-13 14:05:03 +02:00
parent caf47e87ea
commit 4cf408dfa1
7 changed files with 310 additions and 336 deletions

View File

@ -1,12 +1,13 @@
#include <form.h>
#include <ncurses.h>
#include <cstring>
#include <ctime>
#include <format>
#include <string>
#include <vector>
#include "gameske_funkce.h" #include "gameske_funkce.h"
#include "memory.h" #include "memory.h"
#include "strings.h"
#include <cstring>
#include <ctime>
#include <form.h>
#include <format>
#include <ncurses.h>
#include <string>
#include <vector>
#define HEADER_COLOR_PAIR COLOR_RED #define HEADER_COLOR_PAIR COLOR_RED
#define FIELD_NAME_COLOR_PAIR 10 #define FIELD_NAME_COLOR_PAIR 10
@ -16,7 +17,7 @@ std::vector<allocation> editor_easy_allocated;
[[nodiscard]] std::string vytvorTrestniOznameni() { [[nodiscard]] std::string vytvorTrestniOznameni() {
current_allocated = &editor_easy_allocated; current_allocated = &editor_easy_allocated;
auto trim = [](const char* str) -> std::string { auto trim = [](const char *str) -> std::string {
std::string s(str); std::string s(str);
if (s.empty()) if (s.empty())
return s; return s;
@ -34,66 +35,67 @@ std::vector<allocation> editor_easy_allocated;
const int MIN_HEIGHT = 28; const int MIN_HEIGHT = 28;
if (COLS < MIN_WIDTH || LINES < MIN_HEIGHT) { if (COLS < MIN_WIDTH || LINES < MIN_HEIGHT) {
endwin(); endwin();
throw std::runtime_error("Minimální velikost terminálu: 90x28"); throw std::runtime_error(loc_strings->min_terminal_size);
} }
// Nastavení barev // Nastavení barev
start_color(); start_color();
init_pair(FIELD_NAME_COLOR_PAIR, COLOR_BLACK, COLOR_CYAN); // Popisky init_pair(FIELD_NAME_COLOR_PAIR, COLOR_BLACK, COLOR_CYAN); // Popisky
init_pair(INPUT_COLOR_PAIR, COLOR_WHITE, COLOR_BLACK); // Vstupní pole init_pair(INPUT_COLOR_PAIR, COLOR_WHITE, COLOR_BLACK); // Vstupní pole
// Hlavní okno s rámečkem // Hlavní okno s rámečkem
WINDOW* main_win = newwin(LINES - 4, COLS - 4, 2, 2); WINDOW *main_win = newwin(LINES - 4, COLS - 4, 2, 2);
box(main_win, 0, 0); box(main_win, 0, 0);
wrefresh(main_win); wrefresh(main_win);
// Okno pro popisky // Okno pro popisky
WINDOW* label_win = derwin(main_win, LINES - 8, 30, 1, 1); WINDOW *label_win = derwin(main_win, LINES - 8, 30, 1, 1);
wbkgd(label_win, COLOR_PAIR(FIELD_NAME_COLOR_PAIR)); wbkgd(label_win, COLOR_PAIR(FIELD_NAME_COLOR_PAIR));
// Okno pro vstupní pole // Okno pro vstupní pole
WINDOW* field_win = derwin(main_win, LINES - 8, COLS - 38, 1, 32); WINDOW *field_win = derwin(main_win, LINES - 8, COLS - 38, 1, 32);
wbkgd(field_win, COLOR_PAIR(INPUT_COLOR_PAIR)); wbkgd(field_win, COLOR_PAIR(INPUT_COLOR_PAIR));
keypad(field_win, TRUE); keypad(field_win, TRUE);
// Definice polí // Definice polí
struct FieldConfig { struct FieldConfig {
const char* label; const char *label;
int height; int height;
int width; int width;
bool multiline; bool multiline;
}; };
FieldConfig field_configs[] = {{"Jméno podavatele:", 1, 40, false}, FieldConfig field_configs[] = {
{"Adresa podavatele:", 1, 50, false}, {loc_strings->name_of_submiter, 1, 40, false},
{"Telefon podavatele:", 1, 20, false}, {loc_strings->address_of_submiter, 1, 50, false},
{"Email podavatele:", 1, 30, false}, {loc_strings->phone_of_submiter, 1, 20, false},
{loc_strings->email_of_submiter, 1, 30, false},
{"Jméno pachatele:", 1, 40, false}, {loc_strings->name_of_recipient, 1, 40, false},
{"Adresa pachatele:", 1, 50, false}, {loc_strings->address_of_recipient, 1, 50, false},
{"Telefon pachatele:", 1, 20, false}, {loc_strings->phone_of_recipient, 1, 20, false},
{"Email pachatele:", 1, 30, false}, {loc_strings->email_of_recipient, 1, 30, false},
{"Místo činu:", 1, 40, false}, {loc_strings->place_of_incident, 1, 40, false},
{"Datum činu (dd.mm.rrrr):", 1, 15, false}, {loc_strings->date_of_incident, 1, 15, false},
{"Popis činu:", 4, 60, true}, {loc_strings->description_of_incident, 4, 60, true},
{"Důkazy:", 4, 60, true}, {loc_strings->evidence_of_incident, 4, 60, true},
{"Další informace:", 4, 60, true}}; {loc_strings->additional_info, 4, 60, true}};
// Vykreslení popisků // Vykreslení popisků
int label_row = 0; int label_row = 0;
for (const FieldConfig& cfg : field_configs) { for (const FieldConfig &cfg : field_configs) {
mvwprintw(label_win, label_row, 0, "%s", cfg.label); mvwprintw(label_win, label_row, 0, "%s", cfg.label);
label_row += cfg.height + 1; label_row += cfg.height + 1;
} }
wrefresh(label_win); wrefresh(label_win);
// Vytvoření formuláře // Vytvoření formuláře
std::vector<FIELD*> fields; std::vector<FIELD *> fields;
int field_row = 0; int field_row = 0;
for (const FieldConfig& cfg : field_configs) { for (const FieldConfig &cfg : field_configs) {
FIELD* field = new_field(cfg.height, cfg.width, field_row, 0, 0, 0); FIELD *field = new_field(cfg.height, cfg.width, field_row, 0, 0, 0);
set_field_back(field, A_UNDERLINE | COLOR_PAIR(INPUT_COLOR_PAIR)); set_field_back(field, A_UNDERLINE | COLOR_PAIR(INPUT_COLOR_PAIR));
field_opts_off(field, O_AUTOSKIP | O_STATIC); field_opts_off(field, O_AUTOSKIP | O_STATIC);
@ -107,7 +109,7 @@ std::vector<allocation> editor_easy_allocated;
} }
fields.push_back(nullptr); fields.push_back(nullptr);
FORM* form = new_form(&fields[0]); FORM *form = new_form(&fields[0]);
set_form_win(form, field_win); set_form_win(form, field_win);
set_form_sub(form, derwin(field_win, LINES - 10, COLS - 40, 1, 1)); set_form_sub(form, derwin(field_win, LINES - 10, COLS - 40, 1, 1));
@ -116,8 +118,9 @@ std::vector<allocation> editor_easy_allocated;
// Hlavička // Hlavička
attron(COLOR_PAIR(HEADER_COLOR_PAIR)); attron(COLOR_PAIR(HEADER_COLOR_PAIR));
mvprintw(0, (COLS - 40) / 2, "TRESTNÍ OZNÁMENÍ - ZADÁNÍ ÚDAJŮ"); mvprintw(0, (COLS - 40) / 2, "%s",
mvprintw(1, 2, "Vyplňte všechny údaje a stiskněte F10 pro dokončení"); loc_strings->cease_and_desist_entry_of_information);
mvprintw(1, 2, "%s", loc_strings->enter_all_information_and_press_f10);
refresh(); refresh();
// Hlavní smyčka // Hlavní smyčka
@ -125,56 +128,56 @@ std::vector<allocation> editor_easy_allocated;
bool exit_loop = false; bool exit_loop = false;
while (!exit_loop && (ch = wgetch(field_win))) { while (!exit_loop && (ch = wgetch(field_win))) {
switch (ch) { switch (ch) {
case KEY_F(10): case KEY_F(10):
exit_loop = true; exit_loop = true;
break; break;
case KEY_DOWN: case KEY_DOWN:
form_driver(form, REQ_NEXT_FIELD);
form_driver(form, REQ_END_LINE);
break;
case KEY_UP:
form_driver(form, REQ_PREV_FIELD);
form_driver(form, REQ_END_LINE);
break;
case KEY_LEFT:
form_driver(form, REQ_PREV_CHAR);
break;
case KEY_RIGHT:
form_driver(form, REQ_NEXT_CHAR);
break;
case KEY_BACKSPACE:
case 127:
form_driver(form, REQ_DEL_PREV);
break;
case KEY_DC:
form_driver(form, REQ_DEL_CHAR);
break;
case 10: // Enter
if (field_configs[current_field(form)->index].multiline) {
form_driver(form, REQ_NEW_LINE);
} else {
form_driver(form, REQ_NEXT_FIELD); form_driver(form, REQ_NEXT_FIELD);
form_driver(form, REQ_END_LINE); }
break; break;
case KEY_UP: case '\t':
form_driver(form, REQ_PREV_FIELD); form_driver(form, REQ_NEXT_FIELD);
form_driver(form, REQ_END_LINE); break;
break;
case KEY_LEFT: case KEY_BTAB:
form_driver(form, REQ_PREV_CHAR); form_driver(form, REQ_PREV_FIELD);
break; break;
case KEY_RIGHT: default:
form_driver(form, REQ_NEXT_CHAR); form_driver(form, ch);
break; break;
case KEY_BACKSPACE:
case 127:
form_driver(form, REQ_DEL_PREV);
break;
case KEY_DC:
form_driver(form, REQ_DEL_CHAR);
break;
case 10: // Enter
if (field_configs[current_field(form)->index].multiline) {
form_driver(form, REQ_NEW_LINE);
} else {
form_driver(form, REQ_NEXT_FIELD);
}
break;
case '\t':
form_driver(form, REQ_NEXT_FIELD);
break;
case KEY_BTAB:
form_driver(form, REQ_PREV_FIELD);
break;
default:
form_driver(form, ch);
break;
} }
// Ruční aktualizace všech oken // Ruční aktualizace všech oken
@ -194,7 +197,7 @@ std::vector<allocation> editor_easy_allocated;
// Úklid // Úklid
unpost_form(form); unpost_form(form);
free_form(form); free_form(form);
for (fieldnode*& f : fields) for (fieldnode *&f : fields)
if (f) if (f)
free_field(f); free_field(f);
delwin(label_win); delwin(label_win);
@ -205,81 +208,43 @@ std::vector<allocation> editor_easy_allocated;
// Aktuální datum // Aktuální datum
std::time_t t = std::time(nullptr); std::time_t t = std::time(nullptr);
std::tm* now = std::localtime(&t); std::tm *now = std::localtime(&t);
char date_str[100]; char date_str[100];
std::strftime(date_str, sizeof(date_str), "%d.%m.%Y", now); std::strftime(date_str, sizeof(date_str), "%d.%m.%Y", now);
// Formátování trestního oznámení pomocí std::format (C++20/C++23) auto name_thing_args = std::make_format_args(field_values[7]);
std::string complaint = std::format( const std::string name_thing =
R"( field_values[7].empty()
VÝZVA K UPUŠTĚNÍ OD PROTIPRÁVNÍHO JEDNÁNÍ ? loc_strings->call_to_stop_illegal_activity
: std::vformat(loc_strings->call_to_stop_illegal_activity_with_name,
name_thing_args);
V {} dne {} auto comp_args = std::make_format_args(
field_values[4], // Místo
Adresát: date_str, // Aktuální datum
Jméno a příjmení: {} field_values[7], // Jméno a příjmení adresáta
Adresa: {} field_values[10], // Adresa adresáta (přidejte do pole)
Telefon: {} field_values[11], // Telefon adresáta (přidejte do pole)
Email: {} field_values[12], // Email adresáta (přidejte do pole)
Odesílatel:
Jméno a příjmení: {}
Adresa: {}
Telefon: {}
Email: {}
Věc: Výzva k okamžitému upuštění od protiprávního jednání
{}
K protiprávnímu jednání došlo dne {} v {}.
Popis protiprávního jednání:
{}
Důkazy:
{}
Další informace:
{}
Pokud neupustíte od výše uvedeného jednání, budu nucen/a podniknout další právní kroky, včetně podání trestního oznámení a vymáhání náhrady škody.
S pozdravem,
............................
{}
(podpis)
*Toto není právní dokument, ale pouze vzor pro informativní účely. Pro právní poradenství se obraťte na kvalifikovaného právníka.*
)",
field_values[4], // Místo
date_str, // Aktuální datum
field_values[7], // Jméno a příjmení adresáta
field_values[10], // Adresa adresáta (přidejte do pole)
field_values[11], // Telefon adresáta (přidejte do pole)
field_values[12], // Email adresáta (přidejte do pole)
// Odesílatel // Odesílatel
field_values[0], // Jméno a příjmení odesílatele field_values[0], // Jméno a příjmení odesílatele
field_values[1], // Adresa odesílatele field_values[1], // Adresa odesílatele
field_values[2], // Telefon odesílatele field_values[2], // Telefon odesílatele
field_values[3], // Email odesílatele field_values[3], // Email odesílatele
field_values[7].empty() name_thing,
? "Tímto Vás vyzývám, abyste okamžitě upustil/a od protiprávního "
"jednání."
: std::format("Tímto Vás, {}, vyzývám, abyste okamžitě upustil/a od "
"protiprávního jednání.",
field_values[7]),
field_values[5], // Datum činu field_values[5], // Datum činu
field_values[4], // Místo činu field_values[4], // Místo činu
field_values[6], // Popis činu field_values[6], // Popis činu
field_values[8], // Důkazy field_values[8], // Důkazy
field_values[9], // Další informace field_values[9], // Další informace
field_values[0] // Jméno pro podpis field_values[0] // Jméno pro podpis
); );
std::string complaint =
std::vformat(loc_strings->criminal_complaint_template, comp_args);
return complaint; return complaint;
} }

View File

@ -1,18 +1,18 @@
#include "gameske_funkce.h" #include "gameske_funkce.h"
#include <curses.h> #include "memory.h"
#include <menu.h>
#include <ncurses.h>
#include <unistd.h>
#include <chrono> #include <chrono>
#include <clocale> #include <clocale>
#include <cstddef> #include <cstddef>
#include <cstdint> #include <cstdint>
#include <cstring> #include <cstring>
#include <curses.h>
#include <format> #include <format>
#include <iostream> #include <iostream>
#include <menu.h>
#include <ncurses.h>
#include <string> #include <string>
#include <thread> #include <thread>
#include "memory.h" #include <unistd.h>
/* /*
size_t spawn_menu(uint16_t begin_y, uint16_t begin_x, const char** choices, size_t spawn_menu(uint16_t begin_y, uint16_t begin_x, const char** choices,
@ -24,26 +24,26 @@ size_t spawn_menu(uint16_t begin_y, uint16_t begin_x, const char** choices,
int i; int i;
sp_items = new ITEM*[n_choices]; sp_items = new ITEM*[n_choices];
// Create items // Create items
for (i = 0; i < n_choices; ++i) { for (i = 0; i < n_choices; ++i) {
sp_items[i] = new_item(choices[i], choices[i]); sp_items[i] = new_item(choices[i], choices[i]);
} }
// Crate menu // Crate menu
sp_menu = new_menu(sp_items); sp_menu = new_menu(sp_items);
// Create the window to be associated with the menu // Create the window to be associated with the menu
sp_menu_win = newwin(10, 40, begin_y, begin_x); sp_menu_win = newwin(10, 40, begin_y, begin_x);
keypad(sp_menu_win, TRUE); keypad(sp_menu_win, TRUE);
// Set main window and sub window // Set main window and sub window
set_menu_win(sp_menu, sp_menu_win); set_menu_win(sp_menu, sp_menu_win);
set_menu_sub(sp_menu, derwin(sp_menu_win, 6, 38, begin_y - 1, begin_x - 3)); set_menu_sub(sp_menu, derwin(sp_menu_win, 6, 38, begin_y - 1, begin_x - 3));
// Set menu mark to the string " * " // Set menu mark to the string " * "
set_menu_mark(sp_menu, " * "); set_menu_mark(sp_menu, " * ");
// Print a border around the main window and print a title // Print a border around the main window and print a title
box(sp_menu_win, 0, 0); box(sp_menu_win, 0, 0);
print_in_middle(sp_menu_win, 1, 0, 40, "My Menu", COLOR_PAIR(1)); print_in_middle(sp_menu_win, 1, 0, 40, "My Menu", COLOR_PAIR(1));
mvwaddch(sp_menu_win, 2, 0, ACS_LTEE); mvwaddch(sp_menu_win, 2, 0, ACS_LTEE);
@ -52,7 +52,7 @@ size_t spawn_menu(uint16_t begin_y, uint16_t begin_x, const char** choices,
mvprintw(LINES - 2, 0, "F1 to exit"); mvprintw(LINES - 2, 0, "F1 to exit");
refresh(); refresh();
// Post the menu // Post the menu
post_menu(sp_menu); post_menu(sp_menu);
wrefresh(sp_menu_win); wrefresh(sp_menu_win);
@ -69,7 +69,7 @@ size_t spawn_menu(uint16_t begin_y, uint16_t begin_x, const char** choices,
} }
size_t selected = item_index(current_item(sp_menu)); size_t selected = item_index(current_item(sp_menu));
// Unpost and free all the memory taken up // Unpost and free all the memory taken up
unpost_menu(sp_menu); unpost_menu(sp_menu);
free_menu(sp_menu); free_menu(sp_menu);
for (i = 0; i < n_choices; ++i) for (i = 0; i < n_choices; ++i)
@ -80,8 +80,8 @@ 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) { const char *string, chtype color) {
int length, x, y; int length, x, y;
float temp; float temp;
@ -109,7 +109,7 @@ std::string spawncmd() {
int pos = 0; int pos = 0;
int ch; int ch;
WINDOW* cmd_win = newwin(3, 40, LINES - 3, 0); WINDOW *cmd_win = newwin(3, 40, LINES - 3, 0);
if (cmd_win == NULL) if (cmd_win == NULL)
return ""; return "";
@ -142,7 +142,7 @@ std::string spawncmd() {
} else if (isprint(ch)) { } else if (isprint(ch)) {
// Printable character // Printable character
cmd[pos] = ch; cmd[pos] = ch;
mvwaddch(cmd_win, 1, 10 + pos, ch); // Echo the character mvwaddch(cmd_win, 1, 10 + pos, ch); // Echo the character
pos++; pos++;
} }
@ -150,7 +150,7 @@ std::string spawncmd() {
} }
wattroff(cmd_win, COLOR_PAIR(COLOR_CYAN)); wattroff(cmd_win, COLOR_PAIR(COLOR_CYAN));
cmd[pos] = '\0'; // Ensure null termination cmd[pos] = '\0'; // Ensure null termination
// Restore echo state as needed // Restore echo state as needed
curs_set(0); curs_set(0);
@ -160,7 +160,7 @@ std::string spawncmd() {
return std::string(cmd); return std::string(cmd);
} }
void async_clock(WINDOW* win, WINDOW* text_win) { void async_clock(WINDOW *win, WINDOW *text_win) {
std::this_thread::sleep_for(std::chrono::milliseconds(100)); std::this_thread::sleep_for(std::chrono::milliseconds(100));
bool prev_echo_state; bool prev_echo_state;
uint16_t prev_y, prev_x; uint16_t prev_y, prev_x;
@ -182,7 +182,7 @@ void async_clock(WINDOW* win, WINDOW* text_win) {
if (dot_pos != std::string::npos) { if (dot_pos != std::string::npos) {
time_str.erase(dot_pos); time_str.erase(dot_pos);
} }
} catch (const std::exception& e) { } catch (const std::exception &e) {
std::clog << "Format error: " << e.what() << std::endl; std::clog << "Format error: " << e.what() << std::endl;
time_str = "Error"; time_str = "Error";
} }
@ -203,12 +203,12 @@ void async_clock(WINDOW* win, WINDOW* text_win) {
void async_clock_init() { void async_clock_init() {
//memory leak // memory leak
WINDOW* win = newwin(3, 10, LINES - 3, COLS - 10); WINDOW *win = newwin(3, 10, LINES - 3, COLS - 10);
current_allocated->push_back({WINDOW_TYPE, win, 1}); current_allocated->push_back({WINDOW_TYPE, win, 1});
//memory leak // memory leak
WINDOW* text_win = newwin(3, 52, LINES - 3, COLS - 10 - 44); WINDOW *text_win = newwin(3, 52, LINES - 3, COLS - 10 - 44);
current_allocated->push_back({WINDOW_TYPE, text_win, 1}); current_allocated->push_back({WINDOW_TYPE, text_win, 1});
std::thread clock_thread(async_clock, win, text_win); std::thread clock_thread(async_clock, win, text_win);

View File

@ -6,14 +6,14 @@
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
size_t spawn_menu(uint16_t begin_y, uint16_t begin_x, const char** choices, size_t spawn_menu(uint16_t begin_y, uint16_t begin_x, const char **choices,
size_t n_choices); size_t n_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); const char *string, chtype color);
std::string spawncmd(); std::string spawncmd();
void async_clock_init(); void async_clock_init();
#endif // PARADOCS_GAFU_H_ #endif // PARADOCS_GAFU_H_

View File

@ -1,14 +1,14 @@
#include <unistd.h>
#include <csignal>
#include <cstdlib>
#include <iostream>
#include <locale>
#include <regex>
#include "color.h" #include "color.h"
#include "const.h" #include "const.h"
#include "menu.h" #include "menu.h"
#include "signal.h" #include "signal.h"
#include "strings.h" #include "strings.h"
#include <csignal>
#include <cstdlib>
#include <iostream>
#include <locale>
#include <regex>
#include <unistd.h>
void PrintHelp() { void PrintHelp() {
std::cout << RED R"( ____ ____ std::cout << RED R"( ____ ____
@ -18,19 +18,20 @@ void PrintHelp() {
\ \ \/\ \L\.\_\ \ \//\ \L\.\_\ \ \_\ \/\ \L\ \/\ \__//\__, `\ \ \ \/\ \L\.\_\ \ \//\ \L\.\_\ \ \_\ \/\ \L\ \/\ \__//\__, `\
\ \_\ \__/.\_\\ \_\\ \__/.\_\\ \____/\ \____/\ \____\/\____/ \ \_\ \__/.\_\\ \_\\ \__/.\_\\ \____/\ \____/\ \____\/\____/
\/_/\/__/\/_/ \/_/ \/__/\/_/ \/___/ \/___/ \/____/\/___/)" \/_/\/__/\/_/ \/_/ \/__/\/_/ \/___/ \/___/ \/____/\/___/)"
<< RESET "\nUsage:\n" << RESET "\n"
<< NAME << " [options]\n" << loc_strings->usage << ":\n"
<< "-h\t\tPrint this help\n" << NAME << " [" << loc_strings->options << "]\n"
<< "-V\t\tPrint version\n"; << "-h\t\t" << loc_strings->print_this_help << "\n"
<< "-V\t\t" << loc_strings->print_version << "\n";
exit(0); exit(0);
} }
void PrintVersion() { void PrintVersion() {
std::cout << NAME << " version " << VERSION << "\n"; std::cout << NAME << loc_strings->version << ": " << VERSION << "\n";
exit(0); exit(0);
} }
int main(int argc, char* argv[]) { int main(int argc, char *argv[]) {
// signal handlers // signal handlers
std::signal(SIGTERM, safe_exit); std::signal(SIGTERM, safe_exit);
std::signal(SIGINT, safe_exit); std::signal(SIGINT, safe_exit);
@ -56,16 +57,17 @@ int main(int argc, char* argv[]) {
int opt; int opt;
while ((opt = getopt(argc, argv, "hV")) != -1) { while ((opt = getopt(argc, argv, "hV")) != -1) {
switch (opt) { switch (opt) {
case 'h': case 'h':
PrintHelp(); PrintHelp();
break; break;
case 'V': case 'V':
PrintVersion(); PrintVersion();
break; break;
default: default:
std::cerr << RED "[ERROR]" << RESET " invalid option: " << (char)optopt std::cerr << RED "[ERROR]" << RESET " " << loc_strings->invalid_option
<< "\ntry: -h\n"; << ": " << (char)optopt << "\n"
return EINVAL; << loc_strings->try_str << ": -h\n";
return EINVAL;
} }
} }
menu(); menu();

View File

@ -1,23 +1,24 @@
#include <curses.h>
#include <menu.h>
#include <ncurses.h>
#include <cstddef>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <locale>
#include "const.h" #include "const.h"
#include "cups.h" #include "cups.h"
#include "editor_easy.h" #include "editor_easy.h"
#include "gameske_funkce.h" #include "gameske_funkce.h"
#include "memory.h" #include "memory.h"
#include "strings.h"
#include "types.h" #include "types.h"
#include <cstddef>
#include <cstdlib>
#include <cstring>
#include <curses.h>
#include <iostream>
#include <locale>
#include <menu.h>
#include <ncurses.h>
std::vector<allocation> main_menu_allocated; std::vector<allocation> main_menu_allocated;
const char* choices[] = {"paradox", "kompromis", "Stereotyp", "Žena"}; const char *choices[] = {"paradox", "kompromis", "Stereotyp", "Žena"};
const char* date[] = {"2023-10-01", "2023-10-02", "2023-10-03", "2023-10-04"}; const char *date[] = {"2023-10-01", "2023-10-02", "2023-10-03", "2023-10-04"};
const char* choices2[] = {"PRINT", "EDIT", "DELETE", "Žena"}; const char *choices2[] = {"PRINT", "EDIT", "DELETE", "Žena"};
void menu() { void menu() {
current_allocated = &main_menu_allocated; current_allocated = &main_menu_allocated;
@ -28,7 +29,7 @@ void menu() {
start_color(); start_color();
cbreak(); cbreak();
noecho(); noecho();
curs_set(0); // Makes cursor invisible curs_set(0); // Makes cursor invisible
keypad(stdscr, TRUE); keypad(stdscr, TRUE);
for (uint8_t i = 0; i < 8; i++) { for (uint8_t i = 0; i < 8; i++) {
init_pair(i, i, COLOR_BLACK); init_pair(i, i, COLOR_BLACK);
@ -40,7 +41,7 @@ void menu() {
complete_menu main_menu = {nullptr, nullptr, 0, nullptr}; complete_menu main_menu = {nullptr, nullptr, 0, nullptr};
main_menu_allocated.push_back({COMPLETE_MENU_TYPE, &main_menu, 1}); main_menu_allocated.push_back({COMPLETE_MENU_TYPE, &main_menu, 1});
main_menu.items = new ITEM*[ARRAY_SIZE(choices) + 1]; main_menu.items = new ITEM *[ARRAY_SIZE(choices) + 1];
main_menu.items_size = ARRAY_SIZE(choices) + 1; main_menu.items_size = ARRAY_SIZE(choices) + 1;
for (size_t i = 0; i < n_choices; ++i) { for (size_t i = 0; i < n_choices; ++i) {
main_menu.items[i] = new_item(choices[i], date[i]); main_menu.items[i] = new_item(choices[i], date[i]);
@ -63,11 +64,12 @@ void menu() {
/* Print a border around the main window and print a title */ /* Print a border around the main window and print a title */
box(main_menu.win, 0, 0); box(main_menu.win, 0, 0);
print_in_middle(main_menu.win, 1, 0, 40, "My Menu", COLOR_PAIR(1)); print_in_middle(main_menu.win, 1, 0, 40, loc_strings->main_menu,
COLOR_PAIR(1));
mvwaddch(main_menu.win, 2, 0, ACS_LTEE); mvwaddch(main_menu.win, 2, 0, ACS_LTEE);
mvwhline(main_menu.win, 2, 1, ACS_HLINE, 38); mvwhline(main_menu.win, 2, 1, ACS_HLINE, 38);
mvwaddch(main_menu.win, 2, 39, ACS_RTEE); mvwaddch(main_menu.win, 2, 39, ACS_RTEE);
mvprintw(LINES - 2, 0, "F1 to exit"); mvprintw(LINES - 2, 0, "%s", loc_strings->f1_to_exit);
refresh(); refresh();
/* Post the menu */ /* Post the menu */
@ -77,33 +79,33 @@ void menu() {
int c; int c;
while ((c = wgetch(main_menu.win)) != KEY_F(1)) { while ((c = wgetch(main_menu.win)) != KEY_F(1)) {
switch (c) { switch (c) {
case KEY_DOWN: case KEY_DOWN:
menu_driver(main_menu.menu, REQ_DOWN_ITEM); menu_driver(main_menu.menu, REQ_DOWN_ITEM);
break; break;
case KEY_UP: case KEY_UP:
menu_driver(main_menu.menu, REQ_UP_ITEM); menu_driver(main_menu.menu, REQ_UP_ITEM);
break; break;
case 10: case 10:
refresh(); refresh();
break;
case ':':
switch (hash_djb2a(spawncmd())) {
case "print"_sh:
case "p"_sh:
// DONT FORGET TO PRINT ACTUAL DOCUMENT
printDocument("test");
current_allocated = &main_menu_allocated;
break; break;
case ':': case "easy_edit"_sh:
switch (hash_djb2a(spawncmd())) { case "ee"_sh:
case "print"_sh: std::clog << vytvorTrestniOznameni();
case "p"_sh: break;
// DONT FORGET TO PRINT ACTUAL DOCUMENT default:
printDocument("test"); print_in_middle(main_menu.win, 10, 0, 40, loc_strings->unknown_command,
current_allocated = &main_menu_allocated; COLOR_PAIR(1));
break; break;
case "easy_edit"_sh: }
case "ee"_sh:
std::clog << vytvorTrestniOznameni();
break;
default:
print_in_middle(main_menu.win, 10, 0, 40, "Unknown command",
COLOR_PAIR(1));
break;
}
} }
redrawwin(main_menu.win); redrawwin(main_menu.win);
wrefresh(main_menu.win); wrefresh(main_menu.win);

View File

@ -1,13 +1,15 @@
#include "strings.h" #include "strings.h"
strings english_strings{ constexpr strings english_strings{
.invalid_option = "Invalid option:", .invalid_option = "Invalid option:",
.usage = "Usage:", .try_str = "try",
.usage = "Usage",
.options = "OPTIONS", .options = "OPTIONS",
.print_this_help = "Print this help", .print_this_help = "Print this help",
.print_version = "Print version", .print_version = "Print version",
.version = "Version:", .version = "version",
.main_menu = "Main menu", .main_menu = "Main menu",
.f1_to_exit = "F1 to exit",
.unknown_command = "Unknown command:", .unknown_command = "Unknown command:",
.min_terminal_size = "Minimum terminal size: 90x28", .min_terminal_size = "Minimum terminal size: 90x28",
.name_of_submiter = "Name of submiter:", .name_of_submiter = "Name of submiter:",
@ -27,62 +29,66 @@ strings english_strings{
"CEASE AND DESIST - ENTRY OF INFORMATION", "CEASE AND DESIST - ENTRY OF INFORMATION",
.enter_all_information_and_press_f10 = .enter_all_information_and_press_f10 =
"Enter all information and press F10 to finish", "Enter all information and press F10 to finish",
.cease_and_desist_template = R"( .criminal_complaint_template = R"(
CEASE AND DESIST NOTICE CRIMINAL COMPLAINT
In {} on {} To:
Police of the Czech Republic
Recipient: Complainant:
First and last name: {} Name and Surname: {}
Address: {} Address: {}
Phone: {} Phone: {}
Email: {} E-mail: {}
Sender: Accused:
First and last name: {} Name and Surname: {}
Address: {} Address: {}
Phone: {} Phone: {}
Email: {} E-mail: {}
Subject: Notice to immediately cease unlawful conduct Subject:
suspicion of committing a criminal offence
{} Place of submission of the complaint: {}
Date of submission of the complaint: {}
The unlawful conduct occurred on {} in {}. On {} at {} {}.
Description of the unlawful conduct: Factual circumstances:
{} {}
Evidence: Evidence:
{} {}
Additional information: Additional information:
{} {}
If you do not cease the above-mentioned conduct, I will be forced to take further legal action, including filing a criminal complaint and seeking compensation for damages. I request the Police of the Czech Republic to:
Sincerely, take all measures to clarify and investigate the matter,
............................ interview witnesses and secure evidentiary materials,
{}
(signature) submit a proposal to the public prosecutor.
In {}
Signature of the complainant: {}
*This is not a legal document, but only a template for informational purposes. For legal advice, please consult a qualified attorney.* *This is not a legal document, but only a template for informational purposes. For legal advice, please consult a qualified attorney.*
)", )"};
.call_to_stop_illegal_activity =
"I hereby call upon you to immediately cease the unlawful conduct.",
.call_to_stop_illegal_activity_with_name =
"I hereby call upon you, {}, to immediately cease the unlawful "
"conduct."};
strings czech_strings{ constexpr strings czech_strings{
.invalid_option = "Neplatná volba: ", .invalid_option = "Neplatná volba: ",
.usage = "Použití:", .try_str = "zkus",
.usage = "Použití",
.options = "MOŽNOSTI", .options = "MOŽNOSTI",
.print_this_help = "Zobrazit tuto nápovědu", .print_this_help = "Zobrazit tuto nápovědu",
.print_version = "Zobrazit verzi", .print_version = "Zobrazit verzi",
.version = "Verze: ", .version = "verze",
.main_menu = "Hlavní nabídka", .main_menu = "Hlavní nabídka",
.f1_to_exit = "F1 pro ukončení",
.unknown_command = "Neznámý příkaz: ", .unknown_command = "Neznámý příkaz: ",
.min_terminal_size = "Minimální velikost terminálu: 90x28", .min_terminal_size = "Minimální velikost terminálu: 90x28",
.name_of_submiter = "Jméno podavatele: ", .name_of_submiter = "Jméno podavatele: ",
@ -101,51 +107,51 @@ strings czech_strings{
.cease_and_desist_entry_of_information = "TRESTNÍ OZNÁMENÍ - ZADÁNÍ ÚDAJŮ", .cease_and_desist_entry_of_information = "TRESTNÍ OZNÁMENÍ - ZADÁNÍ ÚDAJŮ",
.enter_all_information_and_press_f10 = .enter_all_information_and_press_f10 =
"Zadejte všechny údaje a stiskněte F10 pro dokončení", "Zadejte všechny údaje a stiskněte F10 pro dokončení",
.cease_and_desist_template = R"( .criminal_complaint_template = R"(
VÝZVA K UPUŠTĚNÍ OD PROTIPRÁVNÍHO JEDNÁ TRESTNÍ OZNÁME
V {} dne {} Komu:
Policie ČR
Adresát: Oznamovatel:
Jméno a příjmení: {} Jméno a příjmení: {}
Adresa: {} Adresa: {}
Telefon: {} Telefon: {}
Email: {} E-mail: {}
Odesílatel: Obviněný:
Jméno a příjmení: {} Jméno a příjmení: {}
Adresa: {} Adresa: {}
Telefon: {} Telefon: {}
Email: {} E-mail: {}
Věc: Výzva k okamžitému upuštění od protiprávního jednání Věc:
podezření ze spáchání trestného činu
Místo podání oznámení: {}
Datum podání oznámení: {}
Dne {} v místě {} {}.
1. Skutkové okolnosti:
{} {}
K protiprávnímu jednání došlo dne {} v {}. 2. Důkazy:
Popis protiprávního jednání:
{} {}
Důkazy: 3. Další informace:
{} {}
Další informace: Žádám Policii ČR:
{} - přijmout veškerá opatření k objasnění a prošetření věci,
- vyslechnout svědky a zajistit důkazní materiály,
- podat podnět státnímu zástupci.
Pokud neupustíte od výše uvedeného jednání, budu nucen/a podniknout další právní kroky, včetně podání trestního oznámení a vymáhání náhrady škody. V {}
S pozdravem, Podpis oznamovatele: {}
............................
{}
(podpis)
*Toto není právní dokument, ale pouze vzor pro informativní účely. Pro právní poradenství se obraťte na kvalifikovaného právníka.* *Toto není právní dokument, ale pouze vzor pro informativní účely. Pro právní poradenství se obraťte na kvalifikovaného právníka.*
)", )"};
.call_to_stop_illegal_activity =
"Tímto Vás vyzývám, abyste okamžitě upustil/a od protiprávního " const strings *loc_strings;
"jednání.",
.call_to_stop_illegal_activity_with_name =
"Tímto Vás, {}, vyzývám, abyste okamžitě upustil/a od protiprávního "
"jednání."};

View File

@ -2,42 +2,41 @@
#ifndef PARADOCS_STRINGS_H_ #ifndef PARADOCS_STRINGS_H_
#define PARADOCS_STRINGS_H_ #define PARADOCS_STRINGS_H_
typedef struct { typedef struct {
const char* invalid_option; const char *invalid_option;
const char* usage; const char *try_str;
const char* options; const char *usage;
const char* print_this_help; const char *options;
const char* print_version; const char *print_this_help;
const char* version; const char *print_version;
const char* main_menu; const char *version;
const char* unknown_command; const char *main_menu;
const char *f1_to_exit;
const char *unknown_command;
const char* min_terminal_size; const char *min_terminal_size;
const char* name_of_submiter; const char *name_of_submiter;
const char* address_of_submiter; const char *address_of_submiter;
const char* phone_of_submiter; const char *phone_of_submiter;
const char* email_of_submiter; const char *email_of_submiter;
const char* name_of_recipient; const char *name_of_recipient;
const char* address_of_recipient; const char *address_of_recipient;
const char* phone_of_recipient; const char *phone_of_recipient;
const char* email_of_recipient; const char *email_of_recipient;
const char* place_of_incident; const char *place_of_incident;
const char* date_of_incident; const char *date_of_incident;
const char* description_of_incident; const char *description_of_incident;
const char* evidence_of_incident; const char *evidence_of_incident;
const char* additional_info; const char *additional_info;
const char* cease_and_desist_entry_of_information; const char *cease_and_desist_entry_of_information;
const char* enter_all_information_and_press_f10; const char *enter_all_information_and_press_f10;
const char* cease_and_desist_template; const char *criminal_complaint_template;
const char* call_to_stop_illegal_activity;
const char* call_to_stop_illegal_activity_with_name;
} strings; } strings;
extern strings english_strings; extern const strings english_strings;
extern strings czech_strings; extern const strings czech_strings;
extern strings* loc_strings; extern const strings *loc_strings;
#endif #endif