This commit is contained in:
parent
caf47e87ea
commit
4cf408dfa1
@ -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
|
||||
@ -16,7 +17,7 @@ std::vector<allocation> editor_easy_allocated;
|
||||
|
||||
[[nodiscard]] std::string vytvorTrestniOznameni() {
|
||||
current_allocated = &editor_easy_allocated;
|
||||
auto trim = [](const char* str) -> std::string {
|
||||
auto trim = [](const char *str) -> std::string {
|
||||
std::string s(str);
|
||||
if (s.empty())
|
||||
return s;
|
||||
@ -34,66 +35,67 @@ 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
|
||||
start_color();
|
||||
init_pair(FIELD_NAME_COLOR_PAIR, COLOR_BLACK, COLOR_CYAN); // Popisky
|
||||
init_pair(INPUT_COLOR_PAIR, COLOR_WHITE, COLOR_BLACK); // Vstupní pole
|
||||
init_pair(FIELD_NAME_COLOR_PAIR, COLOR_BLACK, COLOR_CYAN); // Popisky
|
||||
init_pair(INPUT_COLOR_PAIR, COLOR_WHITE, COLOR_BLACK); // Vstupní pole
|
||||
|
||||
// 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);
|
||||
wrefresh(main_win);
|
||||
|
||||
// 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));
|
||||
|
||||
// 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));
|
||||
keypad(field_win, TRUE);
|
||||
|
||||
// Definice polí
|
||||
struct FieldConfig {
|
||||
const char* label;
|
||||
const char *label;
|
||||
int height;
|
||||
int width;
|
||||
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;
|
||||
for (const FieldConfig& cfg : field_configs) {
|
||||
for (const FieldConfig &cfg : field_configs) {
|
||||
mvwprintw(label_win, label_row, 0, "%s", cfg.label);
|
||||
label_row += cfg.height + 1;
|
||||
}
|
||||
wrefresh(label_win);
|
||||
|
||||
// Vytvoření formuláře
|
||||
std::vector<FIELD*> fields;
|
||||
std::vector<FIELD *> fields;
|
||||
int field_row = 0;
|
||||
|
||||
for (const FieldConfig& cfg : field_configs) {
|
||||
FIELD* field = new_field(cfg.height, cfg.width, field_row, 0, 0, 0);
|
||||
for (const FieldConfig &cfg : field_configs) {
|
||||
FIELD *field = new_field(cfg.height, cfg.width, field_row, 0, 0, 0);
|
||||
set_field_back(field, A_UNDERLINE | COLOR_PAIR(INPUT_COLOR_PAIR));
|
||||
field_opts_off(field, O_AUTOSKIP | O_STATIC);
|
||||
|
||||
@ -107,7 +109,7 @@ std::vector<allocation> editor_easy_allocated;
|
||||
}
|
||||
fields.push_back(nullptr);
|
||||
|
||||
FORM* form = new_form(&fields[0]);
|
||||
FORM *form = new_form(&fields[0]);
|
||||
set_form_win(form, field_win);
|
||||
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
|
||||
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
|
||||
@ -125,56 +128,56 @@ std::vector<allocation> editor_easy_allocated;
|
||||
bool exit_loop = false;
|
||||
while (!exit_loop && (ch = wgetch(field_win))) {
|
||||
switch (ch) {
|
||||
case KEY_F(10):
|
||||
exit_loop = true;
|
||||
break;
|
||||
case KEY_F(10):
|
||||
exit_loop = true;
|
||||
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_END_LINE);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case KEY_UP:
|
||||
form_driver(form, REQ_PREV_FIELD);
|
||||
form_driver(form, REQ_END_LINE);
|
||||
break;
|
||||
case '\t':
|
||||
form_driver(form, REQ_NEXT_FIELD);
|
||||
break;
|
||||
|
||||
case KEY_LEFT:
|
||||
form_driver(form, REQ_PREV_CHAR);
|
||||
break;
|
||||
case KEY_BTAB:
|
||||
form_driver(form, REQ_PREV_FIELD);
|
||||
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);
|
||||
}
|
||||
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;
|
||||
default:
|
||||
form_driver(form, ch);
|
||||
break;
|
||||
}
|
||||
|
||||
// Ruční aktualizace všech oken
|
||||
@ -194,7 +197,7 @@ std::vector<allocation> editor_easy_allocated;
|
||||
// Úklid
|
||||
unpost_form(form);
|
||||
free_form(form);
|
||||
for (fieldnode*& f : fields)
|
||||
for (fieldnode *&f : fields)
|
||||
if (f)
|
||||
free_field(f);
|
||||
delwin(label_win);
|
||||
@ -205,81 +208,43 @@ std::vector<allocation> editor_easy_allocated;
|
||||
|
||||
// Aktuální datum
|
||||
std::time_t t = std::time(nullptr);
|
||||
std::tm* now = std::localtime(&t);
|
||||
std::tm *now = std::localtime(&t);
|
||||
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.*
|
||||
)",
|
||||
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)
|
||||
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
|
||||
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
|
||||
field_values[0], // Jméno a příjmení odesílatele
|
||||
field_values[1], // Adresa odesílatele
|
||||
field_values[2], // Telefon odesílatele
|
||||
field_values[3], // Email odesílatele
|
||||
field_values[0], // Jméno a příjmení odesílatele
|
||||
field_values[1], // Adresa odesílatele
|
||||
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
|
||||
field_values[6], // Popis činu
|
||||
field_values[8], // Důkazy
|
||||
field_values[9], // Další informace
|
||||
field_values[0] // Jméno pro podpis
|
||||
field_values[5], // Datum činu
|
||||
field_values[4], // Místo činu
|
||||
field_values[6], // Popis činu
|
||||
field_values[8], // Důkazy
|
||||
field_values[9], // Další informace
|
||||
field_values[0] // Jméno pro podpis
|
||||
);
|
||||
|
||||
std::string complaint =
|
||||
std::vformat(loc_strings->criminal_complaint_template, comp_args);
|
||||
|
||||
return complaint;
|
||||
}
|
||||
|
@ -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,
|
||||
@ -24,26 +24,26 @@ size_t spawn_menu(uint16_t begin_y, uint16_t begin_x, const char** choices,
|
||||
int i;
|
||||
|
||||
sp_items = new ITEM*[n_choices];
|
||||
// Create items
|
||||
// Create items
|
||||
for (i = 0; i < n_choices; ++i) {
|
||||
sp_items[i] = new_item(choices[i], choices[i]);
|
||||
}
|
||||
|
||||
// Crate menu
|
||||
// Crate menu
|
||||
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);
|
||||
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_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, " * ");
|
||||
|
||||
// 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);
|
||||
print_in_middle(sp_menu_win, 1, 0, 40, "My Menu", COLOR_PAIR(1));
|
||||
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");
|
||||
refresh();
|
||||
|
||||
// Post the menu
|
||||
// Post the menu
|
||||
post_menu(sp_menu);
|
||||
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));
|
||||
|
||||
// Unpost and free all the memory taken up
|
||||
// Unpost and free all the memory taken up
|
||||
unpost_menu(sp_menu);
|
||||
free_menu(sp_menu);
|
||||
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,
|
||||
char* string, chtype color) {
|
||||
void print_in_middle(WINDOW *win, int starty, int startx, int width,
|
||||
const char *string, chtype color) {
|
||||
int length, x, y;
|
||||
float temp;
|
||||
|
||||
@ -109,7 +109,7 @@ std::string spawncmd() {
|
||||
int pos = 0;
|
||||
int ch;
|
||||
|
||||
WINDOW* cmd_win = newwin(3, 40, LINES - 3, 0);
|
||||
WINDOW *cmd_win = newwin(3, 40, LINES - 3, 0);
|
||||
if (cmd_win == NULL)
|
||||
return "";
|
||||
|
||||
@ -142,7 +142,7 @@ std::string spawncmd() {
|
||||
} else if (isprint(ch)) {
|
||||
// Printable character
|
||||
cmd[pos] = ch;
|
||||
mvwaddch(cmd_win, 1, 10 + pos, ch); // Echo the character
|
||||
mvwaddch(cmd_win, 1, 10 + pos, ch); // Echo the character
|
||||
pos++;
|
||||
}
|
||||
|
||||
@ -150,7 +150,7 @@ std::string spawncmd() {
|
||||
}
|
||||
wattroff(cmd_win, COLOR_PAIR(COLOR_CYAN));
|
||||
|
||||
cmd[pos] = '\0'; // Ensure null termination
|
||||
cmd[pos] = '\0'; // Ensure null termination
|
||||
// Restore echo state as needed
|
||||
curs_set(0);
|
||||
|
||||
@ -160,7 +160,7 @@ std::string spawncmd() {
|
||||
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));
|
||||
bool prev_echo_state;
|
||||
uint16_t prev_y, prev_x;
|
||||
@ -182,7 +182,7 @@ void async_clock(WINDOW* win, WINDOW* text_win) {
|
||||
if (dot_pos != std::string::npos) {
|
||||
time_str.erase(dot_pos);
|
||||
}
|
||||
} catch (const std::exception& e) {
|
||||
} catch (const std::exception &e) {
|
||||
std::clog << "Format error: " << e.what() << std::endl;
|
||||
time_str = "Error";
|
||||
}
|
||||
@ -203,12 +203,12 @@ void async_clock(WINDOW* win, WINDOW* text_win) {
|
||||
|
||||
void async_clock_init() {
|
||||
|
||||
//memory leak
|
||||
WINDOW* win = newwin(3, 10, LINES - 3, COLS - 10);
|
||||
// memory leak
|
||||
WINDOW *win = newwin(3, 10, LINES - 3, COLS - 10);
|
||||
current_allocated->push_back({WINDOW_TYPE, win, 1});
|
||||
|
||||
//memory leak
|
||||
WINDOW* text_win = newwin(3, 52, LINES - 3, COLS - 10 - 44);
|
||||
// memory leak
|
||||
WINDOW *text_win = newwin(3, 52, LINES - 3, COLS - 10 - 44);
|
||||
current_allocated->push_back({WINDOW_TYPE, text_win, 1});
|
||||
|
||||
std::thread clock_thread(async_clock, win, text_win);
|
||||
|
@ -6,14 +6,14 @@
|
||||
|
||||
#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);
|
||||
|
||||
void print_in_middle(WINDOW* win, int starty, int startx, int width,
|
||||
char* string, chtype color);
|
||||
void print_in_middle(WINDOW *win, int starty, int startx, int width,
|
||||
const char *string, chtype color);
|
||||
|
||||
std::string spawncmd();
|
||||
|
||||
void async_clock_init();
|
||||
|
||||
#endif // PARADOCS_GAFU_H_
|
||||
#endif // PARADOCS_GAFU_H_
|
46
src/main.cpp
46
src/main.cpp
@ -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,19 +18,20 @@ 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);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
int main(int argc, char *argv[]) {
|
||||
// signal handlers
|
||||
std::signal(SIGTERM, safe_exit);
|
||||
std::signal(SIGINT, safe_exit);
|
||||
@ -56,16 +57,17 @@ int main(int argc, char* argv[]) {
|
||||
int opt;
|
||||
while ((opt = getopt(argc, argv, "hV")) != -1) {
|
||||
switch (opt) {
|
||||
case 'h':
|
||||
PrintHelp();
|
||||
break;
|
||||
case 'V':
|
||||
PrintVersion();
|
||||
break;
|
||||
default:
|
||||
std::cerr << RED "[ERROR]" << RESET " invalid option: " << (char)optopt
|
||||
<< "\ntry: -h\n";
|
||||
return EINVAL;
|
||||
case 'h':
|
||||
PrintHelp();
|
||||
break;
|
||||
case 'V':
|
||||
PrintVersion();
|
||||
break;
|
||||
default:
|
||||
std::cerr << RED "[ERROR]" << RESET " " << loc_strings->invalid_option
|
||||
<< ": " << (char)optopt << "\n"
|
||||
<< loc_strings->try_str << ": -h\n";
|
||||
return EINVAL;
|
||||
}
|
||||
}
|
||||
menu();
|
||||
|
82
src/menu.cpp
82
src/menu.cpp
@ -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 "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;
|
||||
|
||||
const char* choices[] = {"paradox", "kompromis", "Stereotyp", "Žena"};
|
||||
const char* date[] = {"2023-10-01", "2023-10-02", "2023-10-03", "2023-10-04"};
|
||||
const char* choices2[] = {"PRINT", "EDIT", "DELETE", "Ž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 *choices2[] = {"PRINT", "EDIT", "DELETE", "Žena"};
|
||||
|
||||
void menu() {
|
||||
current_allocated = &main_menu_allocated;
|
||||
@ -28,7 +29,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);
|
||||
@ -40,7 +41,7 @@ void menu() {
|
||||
complete_menu main_menu = {nullptr, nullptr, 0, nullptr};
|
||||
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;
|
||||
for (size_t i = 0; i < n_choices; ++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 */
|
||||
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 */
|
||||
@ -77,33 +79,33 @@ 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();
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
}
|
||||
case "easy_edit"_sh:
|
||||
case "ee"_sh:
|
||||
std::clog << vytvorTrestniOznameni();
|
||||
break;
|
||||
default:
|
||||
print_in_middle(main_menu.win, 10, 0, 40, loc_strings->unknown_command,
|
||||
COLOR_PAIR(1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
redrawwin(main_menu.win);
|
||||
wrefresh(main_menu.win);
|
||||
|
142
src/strings.cpp
142
src/strings.cpp
@ -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,62 +29,66 @@ 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:
|
||||
{}
|
||||
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,
|
||||
|
||||
............................
|
||||
{}
|
||||
(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ÁNÍ
|
||||
.criminal_complaint_template = R"(
|
||||
TRESTNÍ OZNÁMENÍ
|
||||
|
||||
V {} dne {}
|
||||
Komu:
|
||||
Policie ČR
|
||||
|
||||
Adresát:
|
||||
Jméno a příjmení: {}
|
||||
Adresa: {}
|
||||
Telefon: {}
|
||||
Email: {}
|
||||
Oznamovatel:
|
||||
Jméno a příjmení: {}
|
||||
Adresa: {}
|
||||
Telefon: {}
|
||||
E-mail: {}
|
||||
|
||||
Odesílatel:
|
||||
Jméno a příjmení: {}
|
||||
Adresa: {}
|
||||
Telefon: {}
|
||||
Email: {}
|
||||
Obviněný:
|
||||
Jméno a příjmení: {}
|
||||
Adresa: {}
|
||||
Telefon: {}
|
||||
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;
|
@ -2,42 +2,41 @@
|
||||
#ifndef PARADOCS_STRINGS_H_
|
||||
#define PARADOCS_STRINGS_H_
|
||||
typedef struct {
|
||||
const char* invalid_option;
|
||||
const char* usage;
|
||||
const char* options;
|
||||
const char* print_this_help;
|
||||
const char* print_version;
|
||||
const char* version;
|
||||
const char* main_menu;
|
||||
const char* unknown_command;
|
||||
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;
|
||||
const char* name_of_submiter;
|
||||
const char* address_of_submiter;
|
||||
const char* phone_of_submiter;
|
||||
const char* email_of_submiter;
|
||||
const char *min_terminal_size;
|
||||
const char *name_of_submiter;
|
||||
const char *address_of_submiter;
|
||||
const char *phone_of_submiter;
|
||||
const char *email_of_submiter;
|
||||
|
||||
const char* name_of_recipient;
|
||||
const char* address_of_recipient;
|
||||
const char* phone_of_recipient;
|
||||
const char* email_of_recipient;
|
||||
const char *name_of_recipient;
|
||||
const char *address_of_recipient;
|
||||
const char *phone_of_recipient;
|
||||
const char *email_of_recipient;
|
||||
|
||||
const char* place_of_incident;
|
||||
const char* date_of_incident;
|
||||
const char* description_of_incident;
|
||||
const char* evidence_of_incident;
|
||||
const char* additional_info;
|
||||
const char *place_of_incident;
|
||||
const char *date_of_incident;
|
||||
const char *description_of_incident;
|
||||
const char *evidence_of_incident;
|
||||
const char *additional_info;
|
||||
|
||||
const char* cease_and_desist_entry_of_information;
|
||||
const char* enter_all_information_and_press_f10;
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user