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 "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 FIELD_NAME_COLOR_PAIR 10
@ -34,7 +35,7 @@ std::vector<allocation> editor_easy_allocated;
const int MIN_HEIGHT = 28;
if (COLS < MIN_WIDTH || LINES < MIN_HEIGHT) {
endwin();
throw std::runtime_error("Minimální velikost terminálu: 90x28");
throw std::runtime_error(loc_strings->min_terminal_size);
}
// Nastavení barev
@ -64,21 +65,22 @@ std::vector<allocation> editor_easy_allocated;
bool multiline;
};
FieldConfig field_configs[] = {{"Jméno podavatele:", 1, 40, false},
{"Adresa podavatele:", 1, 50, false},
{"Telefon podavatele:", 1, 20, false},
{"Email podavatele:", 1, 30, false},
FieldConfig field_configs[] = {
{loc_strings->name_of_submiter, 1, 40, false},
{loc_strings->address_of_submiter, 1, 50, false},
{loc_strings->phone_of_submiter, 1, 20, false},
{loc_strings->email_of_submiter, 1, 30, false},
{"Jméno pachatele:", 1, 40, false},
{"Adresa pachatele:", 1, 50, false},
{"Telefon pachatele:", 1, 20, false},
{"Email pachatele:", 1, 30, false},
{loc_strings->name_of_recipient, 1, 40, false},
{loc_strings->address_of_recipient, 1, 50, false},
{loc_strings->phone_of_recipient, 1, 20, false},
{loc_strings->email_of_recipient, 1, 30, false},
{"Místo činu:", 1, 40, false},
{"Datum činu (dd.mm.rrrr):", 1, 15, false},
{"Popis činu:", 4, 60, true},
{"Důkazy:", 4, 60, true},
{"Další informace:", 4, 60, true}};
{loc_strings->place_of_incident, 1, 40, false},
{loc_strings->date_of_incident, 1, 15, false},
{loc_strings->description_of_incident, 4, 60, true},
{loc_strings->evidence_of_incident, 4, 60, true},
{loc_strings->additional_info, 4, 60, true}};
// Vykreslení popisků
int label_row = 0;
@ -116,8 +118,9 @@ std::vector<allocation> editor_easy_allocated;
// Hlavička
attron(COLOR_PAIR(HEADER_COLOR_PAIR));
mvprintw(0, (COLS - 40) / 2, "TRESTNÍ OZNÁMENÍ - ZADÁNÍ ÚDAJŮ");
mvprintw(1, 2, "Vyplňte všechny údaje a stiskněte F10 pro dokončení");
mvprintw(0, (COLS - 40) / 2, "%s",
loc_strings->cease_and_desist_entry_of_information);
mvprintw(1, 2, "%s", loc_strings->enter_all_information_and_press_f10);
refresh();
// Hlavní smyčka
@ -209,50 +212,14 @@ std::vector<allocation> editor_easy_allocated;
char date_str[100];
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)
std::string complaint = std::format(
R"(
VÝZVA K UPUŠTĚNÍ OD PROTIPRÁVNÍHO JEDNÁNÍ
auto name_thing_args = std::make_format_args(field_values[7]);
const std::string name_thing =
field_values[7].empty()
? loc_strings->call_to_stop_illegal_activity
: std::vformat(loc_strings->call_to_stop_illegal_activity_with_name,
name_thing_args);
V {} dne {}
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.*
)",
auto comp_args = std::make_format_args(
field_values[4], // Místo
date_str, // Aktuální datum
field_values[7], // Jméno a příjmení adresáta
@ -266,12 +233,7 @@ S pozdravem,
field_values[2], // Telefon odesílatele
field_values[3], // Email odesílatele
field_values[7].empty()
? "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]),
name_thing,
field_values[5], // Datum činu
field_values[4], // Místo činu
@ -281,5 +243,8 @@ S pozdravem,
field_values[0] // Jméno pro podpis
);
std::string complaint =
std::vformat(loc_strings->criminal_complaint_template, comp_args);
return complaint;
}

View File

@ -1,18 +1,18 @@
#include "gameske_funkce.h"
#include <curses.h>
#include <menu.h>
#include <ncurses.h>
#include <unistd.h>
#include "memory.h"
#include <chrono>
#include <clocale>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <curses.h>
#include <format>
#include <iostream>
#include <menu.h>
#include <ncurses.h>
#include <string>
#include <thread>
#include "memory.h"
#include <unistd.h>
/*
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,
char* string, chtype color) {
const char *string, chtype color) {
int length, x, y;
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);
void print_in_middle(WINDOW *win, int starty, int startx, int width,
char* string, chtype color);
const char *string, chtype color);
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 "const.h"
#include "menu.h"
#include "signal.h"
#include "strings.h"
#include <csignal>
#include <cstdlib>
#include <iostream>
#include <locale>
#include <regex>
#include <unistd.h>
void PrintHelp() {
std::cout << RED R"( ____ ____
@ -18,15 +18,16 @@ void PrintHelp() {
\ \ \/\ \L\.\_\ \ \//\ \L\.\_\ \ \_\ \/\ \L\ \/\ \__//\__, `\
\ \_\ \__/.\_\\ \_\\ \__/.\_\\ \____/\ \____/\ \____\/\____/
\/_/\/__/\/_/ \/_/ \/__/\/_/ \/___/ \/___/ \/____/\/___/)"
<< RESET "\nUsage:\n"
<< NAME << " [options]\n"
<< "-h\t\tPrint this help\n"
<< "-V\t\tPrint version\n";
<< RESET "\n"
<< loc_strings->usage << ":\n"
<< NAME << " [" << loc_strings->options << "]\n"
<< "-h\t\t" << loc_strings->print_this_help << "\n"
<< "-V\t\t" << loc_strings->print_version << "\n";
exit(0);
}
void PrintVersion() {
std::cout << NAME << " version " << VERSION << "\n";
std::cout << NAME << loc_strings->version << ": " << VERSION << "\n";
exit(0);
}
@ -63,8 +64,9 @@ int main(int argc, char* argv[]) {
PrintVersion();
break;
default:
std::cerr << RED "[ERROR]" << RESET " invalid option: " << (char)optopt
<< "\ntry: -h\n";
std::cerr << RED "[ERROR]" << RESET " " << loc_strings->invalid_option
<< ": " << (char)optopt << "\n"
<< loc_strings->try_str << ": -h\n";
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 "cups.h"
#include "editor_easy.h"
#include "gameske_funkce.h"
#include "memory.h"
#include "strings.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;
@ -63,11 +64,12 @@ void menu() {
/* Print a border around the main window and print a title */
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);
mvwhline(main_menu.win, 2, 1, ACS_HLINE, 38);
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();
/* Post the menu */
@ -100,7 +102,7 @@ void menu() {
std::clog << vytvorTrestniOznameni();
break;
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));
break;
}

View File

@ -1,13 +1,15 @@
#include "strings.h"
strings english_strings{
constexpr strings english_strings{
.invalid_option = "Invalid option:",
.usage = "Usage:",
.try_str = "try",
.usage = "Usage",
.options = "OPTIONS",
.print_this_help = "Print this help",
.print_version = "Print version",
.version = "Version:",
.version = "version",
.main_menu = "Main menu",
.f1_to_exit = "F1 to exit",
.unknown_command = "Unknown command:",
.min_terminal_size = "Minimum terminal size: 90x28",
.name_of_submiter = "Name of submiter:",
@ -27,30 +29,33 @@ strings english_strings{
"CEASE AND DESIST - ENTRY OF INFORMATION",
.enter_all_information_and_press_f10 =
"Enter all information and press F10 to finish",
.cease_and_desist_template = R"(
CEASE AND DESIST NOTICE
.criminal_complaint_template = R"(
CRIMINAL COMPLAINT
In {} on {}
To:
Police of the Czech Republic
Recipient:
First and last name: {}
Complainant:
Name and Surname: {}
Address: {}
Phone: {}
Email: {}
E-mail: {}
Sender:
First and last name: {}
Accused:
Name and Surname: {}
Address: {}
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:
@ -59,30 +64,31 @@ Evidence:
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,
............................
{}
(signature)
interview witnesses and secure evidentiary materials,
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.*
)",
.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: ",
.usage = "Použití:",
.try_str = "zkus",
.usage = "Použití",
.options = "MOŽNOSTI",
.print_this_help = "Zobrazit tuto nápovědu",
.print_version = "Zobrazit verzi",
.version = "Verze: ",
.version = "verze",
.main_menu = "Hlavní nabídka",
.f1_to_exit = "F1 pro ukončení",
.unknown_command = "Neznámý příkaz: ",
.min_terminal_size = "Minimální velikost terminálu: 90x28",
.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Ů",
.enter_all_information_and_press_f10 =
"Zadejte všechny údaje a stiskněte F10 pro dokončení",
.cease_and_desist_template = R"(
VÝZVA K UPUŠTĚNÍ OD PROTIPRÁVNÍHO JEDNÁ
.criminal_complaint_template = R"(
TRESTNÍ OZNÁME
V {} dne {}
Komu:
Policie ČR
Adresát:
Oznamovatel:
Jméno a příjmení: {}
Adresa: {}
Telefon: {}
Email: {}
E-mail: {}
Odesílatel:
Obviněný:
Jméno a příjmení: {}
Adresa: {}
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 {}.
Popis protiprávního jednání:
2. Důkazy:
{}
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)
Podpis oznamovatele: {}
*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 "
"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í."};
)"};
const strings *loc_strings;

View File

@ -3,12 +3,14 @@
#define PARADOCS_STRINGS_H_
typedef struct {
const char *invalid_option;
const char *try_str;
const char *usage;
const char *options;
const char *print_this_help;
const char *print_version;
const char *version;
const char *main_menu;
const char *f1_to_exit;
const char *unknown_command;
const char *min_terminal_size;
@ -31,13 +33,10 @@ typedef struct {
const char *cease_and_desist_entry_of_information;
const char *enter_all_information_and_press_f10;
const char* cease_and_desist_template;
const char* call_to_stop_illegal_activity;
const char* call_to_stop_illegal_activity_with_name;
const char *criminal_complaint_template;
} strings;
extern strings english_strings;
extern strings czech_strings;
extern strings* loc_strings;
extern const strings english_strings;
extern const strings czech_strings;
extern const strings *loc_strings;
#endif