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
@ -34,7 +35,7 @@ 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
@ -64,21 +65,22 @@ std::vector<allocation> editor_easy_allocated;
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;
@ -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
@ -209,50 +212,14 @@ std::vector<allocation> editor_easy_allocated;
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(
Adresát:
Jméno a příjmení: {}
Adresa: {}
Telefon: {}
Email: {}
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 field_values[4], // Místo
date_str, // Aktuální datum date_str, // Aktuální datum
field_values[7], // Jméno a příjmení adresáta field_values[7], // Jméno a příjmení adresáta
@ -266,12 +233,7 @@ S pozdravem,
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
@ -281,5 +243,8 @@ S pozdravem,
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,
@ -81,7 +81,7 @@ 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;

View File

@ -10,7 +10,7 @@ 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();

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,15 +18,16 @@ 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);
} }
@ -63,8 +64,9 @@ int main(int argc, char* argv[]) {
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"
<< loc_strings->try_str << ": -h\n";
return EINVAL; return EINVAL;
} }
} }

View File

@ -1,17 +1,18 @@
#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;
@ -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 */
@ -100,7 +102,7 @@ void menu() {
std::clog << vytvorTrestniOznameni(); std::clog << vytvorTrestniOznameni();
break; break;
default: default:
print_in_middle(main_menu.win, 10, 0, 40, "Unknown command", print_in_middle(main_menu.win, 10, 0, 40, loc_strings->unknown_command,
COLOR_PAIR(1)); COLOR_PAIR(1));
break; break;
} }

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,30 +29,33 @@ 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:
@ -59,30 +64,31 @@ 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

@ -3,12 +3,14 @@
#define PARADOCS_STRINGS_H_ #define PARADOCS_STRINGS_H_
typedef struct { typedef struct {
const char *invalid_option; const char *invalid_option;
const char *try_str;
const char *usage; const char *usage;
const char *options; const char *options;
const char *print_this_help; const char *print_this_help;
const char *print_version; const char *print_version;
const char *version; const char *version;
const char *main_menu; const char *main_menu;
const char *f1_to_exit;
const char *unknown_command; const char *unknown_command;
const char *min_terminal_size; const char *min_terminal_size;
@ -31,13 +33,10 @@ typedef struct {
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