Compare commits
20 Commits
57d8b13f19
...
v1.0.0
| Author | SHA1 | Date | |
|---|---|---|---|
| e6961d6d6d | |||
| 00f261696f | |||
| d330878f8a | |||
| 30c8ad2ca7 | |||
| edd21acaa5 | |||
| bf02560cdd | |||
| dded22125c | |||
| 2a374dbf4b | |||
| a9e9dfc85b | |||
| 7f427a47fc | |||
| eaf6f44464 | |||
| 0a07589e0e | |||
| ff9303861a | |||
| 4b7644bd4f | |||
| 6c8840b3e5 | |||
| 87768dedf4 | |||
| e92069c8db | |||
| 4cf408dfa1 | |||
| caf47e87ea | |||
| d79047665e |
@@ -6,10 +6,10 @@ jobs:
|
|||||||
runs-on: arch
|
runs-on: arch
|
||||||
steps:
|
steps:
|
||||||
- name: get dependencies
|
- name: get dependencies
|
||||||
run: pacman -Sy nodejs make gcc libcups --needed --noconfirm
|
run: pacman -Sy nodejs make gcc libcups nlohmann-json --needed --noconfirm
|
||||||
|
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: make -j$(nproc)
|
run: make -j$(nproc)
|
||||||
|
|||||||
@@ -4,3 +4,4 @@ compile_commands.json
|
|||||||
core*
|
core*
|
||||||
build
|
build
|
||||||
log
|
log
|
||||||
|
complaints
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
# Compiler and flags
|
# Compiler and flags
|
||||||
CPPC = g++
|
CPPC = g++
|
||||||
CPPC_FLAGS = -std=c++23 -s -O3 -Wall -Wextra -Wno-write-strings -lncurses -lmenu -lform -lcups
|
CPPC_FLAGS = -std=c++23 -s -O3 -Wall -Wextra -lncurses -lmenu -lform -lcups
|
||||||
DEBUG_FLAGS = -ggdb -std=c++23 -Wall -Wextra -Wno-write-strings -lncurses -lmenu -lform -lcups
|
DEBUG_FLAGS = -ggdb -std=c++23 -Wall -lncurses -lmenu -lform -lcups
|
||||||
DEBUG_ASANITIZE = -fsanitize=address -ggdb -fno-omit-frame-pointer -std=c++23 -lncurses -lmenu -lcups -Wall -Wextra -Wno-write-strings
|
DEBUG_ASANITIZE = -fsanitize=address -ggdb -fno-omit-frame-pointer -std=c++23 -lncurses -lmenu -lform -lcups -Wall -Wextra
|
||||||
|
|
||||||
|
|
||||||
SRC_PATH := src
|
SRC_PATH := src
|
||||||
|
|||||||
+4
-2
@@ -3,7 +3,7 @@
|
|||||||
#ifndef NAME
|
#ifndef NAME
|
||||||
|
|
||||||
#define NAME "ParaDocs"
|
#define NAME "ParaDocs"
|
||||||
#define VERSION "0.0.1"
|
#define VERSION "1.0.0"
|
||||||
|
|
||||||
inline constexpr auto hash_djb2a(const std::string_view sv) {
|
inline constexpr auto hash_djb2a(const std::string_view sv) {
|
||||||
unsigned long hash{5381};
|
unsigned long hash{5381};
|
||||||
@@ -13,8 +13,10 @@ inline constexpr auto hash_djb2a(const std::string_view sv) {
|
|||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline constexpr auto operator"" _sh(const char* str, size_t len) {
|
inline constexpr auto operator""_sh(const char *str, size_t len) {
|
||||||
return hash_djb2a(std::string_view{str, len});
|
return hash_djb2a(std::string_view{str, len});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum { NOT_SEND, SEND, REJECTED, ACCEPTED, STATUS_COUNT };
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
+138
-150
@@ -1,16 +1,22 @@
|
|||||||
|
#include "gameske_funkce.h"
|
||||||
|
#include "memory.h"
|
||||||
|
#include "strings.h"
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <form.h>
|
#include <form.h>
|
||||||
#include <format> // C++20/C++23 feature
|
#include <format>
|
||||||
#include <ncurses.h>
|
#include <ncurses.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#define WHITE_ON_BLUE 9
|
#define HEADER_COLOR_PAIR COLOR_RED
|
||||||
#define BLACK_ON_WHITE 10
|
#define FIELD_NAME_COLOR_PAIR 10
|
||||||
|
#define INPUT_COLOR_PAIR 11
|
||||||
|
|
||||||
|
std::vector<allocation> editor_easy_allocated;
|
||||||
|
|
||||||
[[nodiscard]] std::string vytvorTrestniOznameni() {
|
[[nodiscard]] std::string vytvorTrestniOznameni() {
|
||||||
// Pomocná funkce pro ořezání mezer (ncurses vyplňuje pole mezerami)
|
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())
|
||||||
@@ -22,168 +28,183 @@
|
|||||||
return s.substr(start, end - start + 1);
|
return s.substr(start, end - start + 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
init_pair(WHITE_ON_BLUE, COLOR_WHITE, COLOR_BLUE);
|
curs_set(1);
|
||||||
init_pair(BLACK_ON_WHITE, COLOR_BLACK, COLOR_WHITE);
|
|
||||||
|
|
||||||
// Velikost terminalu
|
// Minimální velikost terminálu
|
||||||
int max_y, max_x;
|
const int MIN_WIDTH = 90;
|
||||||
getmaxyx(stdscr, max_y, max_x);
|
const int MIN_HEIGHT = 28;
|
||||||
|
if (COLS < MIN_WIDTH || LINES < MIN_HEIGHT) {
|
||||||
|
endwin();
|
||||||
|
throw std::runtime_error(loc_strings->min_terminal_size);
|
||||||
|
}
|
||||||
|
|
||||||
echo();
|
// 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
|
||||||
|
|
||||||
// Nadpis
|
// Hlavní okno s rámečkem
|
||||||
attron(COLOR_PAIR(WHITE_ON_BLUE));
|
WINDOW *main_win = newwin(LINES - 4, COLS - 4, 2, 2);
|
||||||
mvprintw(0, 0, "TRESTNÍ OZNÁMENÍ - ZADÁNÍ ÚDAJŮ");
|
box(main_win, 0, 0);
|
||||||
for (int i = strlen("TRESTNÍ OZNÁMENÍ - ZADÁNÍ ÚDAJŮ"); i < max_x; i++)
|
wrefresh(main_win);
|
||||||
addch(' ');
|
|
||||||
attroff(COLOR_PAIR(WHITE_ON_BLUE));
|
|
||||||
|
|
||||||
// Vytvoření polí formuláře
|
// Okno pro popisky
|
||||||
const int NUM_FIELDS = 10;
|
WINDOW *label_win = derwin(main_win, LINES - 8, 30, 1, 1);
|
||||||
FIELD *fields[NUM_FIELDS + 1]; // +1 pro NULL terminátor
|
wbkgd(label_win, COLOR_PAIR(FIELD_NAME_COLOR_PAIR));
|
||||||
|
|
||||||
// Definice popisků a vlastností polí
|
// Okno pro vstupní pole
|
||||||
struct FieldInfo {
|
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 height;
|
||||||
int width;
|
int width;
|
||||||
bool multiline;
|
bool multiline;
|
||||||
};
|
};
|
||||||
|
|
||||||
FieldInfo field_info[NUM_FIELDS] = {
|
FieldConfig field_configs[] = {
|
||||||
{"Jméno a příjmení:", 1, 40, false},
|
{loc_strings->name_of_submiter, 1, 40, false},
|
||||||
{"Adresa:", 1, 50, false},
|
{loc_strings->address_of_submiter, 1, 50, false},
|
||||||
{"Telefon:", 1, 20, false},
|
{loc_strings->phone_of_submiter, 1, 20, false},
|
||||||
{"Email:", 1, 30, false},
|
{loc_strings->email_of_submiter, 1, 30, false},
|
||||||
{"Místo činu:", 1, 40, false},
|
|
||||||
{"Datum činu (dd.mm.rrrr):", 1, 15, false},
|
|
||||||
{"Popis činu:", 5, 60, true},
|
|
||||||
{"Jméno pachatele (pokud známo):", 1, 40, false},
|
|
||||||
{"Důkazy:", 4, 60, true},
|
|
||||||
{"Další informace:", 3, 60, true}};
|
|
||||||
|
|
||||||
// Vytvoření polí
|
{loc_strings->name_of_recipient, 1, 40, false},
|
||||||
int row = 2;
|
{loc_strings->address_of_recipient, 1, 50, false},
|
||||||
for (int i = 0; i < NUM_FIELDS; i++) {
|
{loc_strings->phone_of_recipient, 1, 20, false},
|
||||||
mvprintw(row, 2, "%s", field_info[i].label);
|
{loc_strings->email_of_recipient, 1, 30, false},
|
||||||
|
|
||||||
fields[i] = new_field(field_info[i].height, field_info[i].width, row,
|
{loc_strings->place_of_incident, 1, 40, false},
|
||||||
30, // Začátek pole po popisku
|
{loc_strings->date_of_incident, 1, 15, false},
|
||||||
0, 0);
|
{loc_strings->description_of_incident, 4, 60, true},
|
||||||
|
{loc_strings->evidence_of_incident, 4, 60, true},
|
||||||
|
{loc_strings->additional_info, 4, 60, true}};
|
||||||
|
|
||||||
// Nastavení vlastností pole
|
// Vykreslení popisků
|
||||||
set_field_back(fields[i], A_UNDERLINE);
|
int label_row = 0;
|
||||||
field_opts_off(fields[i], O_AUTOSKIP);
|
for (const FieldConfig &cfg : field_configs) {
|
||||||
|
mvwprintw(label_win, label_row, 0, "%s", cfg.label);
|
||||||
// Pro víceřádková pole
|
label_row += cfg.height + 1;
|
||||||
if (field_info[i].multiline) {
|
|
||||||
field_opts_off(fields[i], O_STATIC);
|
|
||||||
field_opts_on(fields[i], O_WRAP);
|
|
||||||
}
|
|
||||||
|
|
||||||
row += field_info[i].height + 1;
|
|
||||||
}
|
}
|
||||||
fields[NUM_FIELDS] = NULL;
|
wrefresh(label_win);
|
||||||
|
|
||||||
// Vytvoření formuláře
|
// Vytvoření formuláře
|
||||||
FORM *form = new_form(fields);
|
std::vector<FIELD *> fields;
|
||||||
|
int field_row = 0;
|
||||||
|
|
||||||
// Vytvoření oken pro formulář
|
for (const FieldConfig &cfg : field_configs) {
|
||||||
WINDOW *win_body = newwin(max_y, max_x, 0, 0);
|
FIELD *field = new_field(cfg.height, cfg.width, field_row, 0, 0, 0);
|
||||||
WINDOW *win_form = derwin(win_body, max_y - 5, max_x - 4, 1, 2);
|
set_field_back(field, A_UNDERLINE | COLOR_PAIR(INPUT_COLOR_PAIR));
|
||||||
|
field_opts_off(field, O_AUTOSKIP | O_STATIC);
|
||||||
|
|
||||||
// Přiřazení oken k formuláři
|
if (cfg.multiline) {
|
||||||
set_form_win(form, win_body);
|
field_opts_on(field, O_WRAP);
|
||||||
set_form_sub(form, win_form);
|
set_max_field(field, 500);
|
||||||
|
}
|
||||||
|
|
||||||
|
fields.push_back(field);
|
||||||
|
field_row += cfg.height + 1;
|
||||||
|
}
|
||||||
|
fields.push_back(nullptr);
|
||||||
|
|
||||||
|
FORM *form = new_form(&fields[0]);
|
||||||
|
set_form_win(form, field_win);
|
||||||
|
set_form_sub(form, derwin(field_win, LINES - 10, COLS - 40, 0, 1));
|
||||||
|
|
||||||
// Zobrazení formuláře
|
|
||||||
post_form(form);
|
post_form(form);
|
||||||
|
form_driver(form, REQ_FIRST_FIELD);
|
||||||
|
|
||||||
// Zobrazení instrukcí
|
// Hlavička
|
||||||
mvprintw(max_y - 3, 2,
|
attron(COLOR_PAIR(HEADER_COLOR_PAIR));
|
||||||
"Navigace: šipky - pohyb | Tab - další pole | Enter - nový řádek | "
|
mvprintw(0, (COLS - 40) / 2, "%s",
|
||||||
"F10 - uložit");
|
loc_strings->cease_and_desist_entry_of_information);
|
||||||
|
mvprintw(1, 2, "%s", loc_strings->enter_all_information_and_press_f10);
|
||||||
refresh();
|
refresh();
|
||||||
wrefresh(win_body);
|
|
||||||
|
|
||||||
// Zpracování vstupu od uživatele
|
// Hlavní smyčka
|
||||||
int ch;
|
int ch;
|
||||||
while ((ch = getch()) != KEY_F(10)) {
|
bool exit_loop = false;
|
||||||
|
while (!exit_loop && (ch = wgetch(field_win))) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
|
case KEY_F(10):
|
||||||
|
exit_loop = true;
|
||||||
|
break;
|
||||||
|
|
||||||
case KEY_DOWN:
|
case KEY_DOWN:
|
||||||
form_driver(form, REQ_NEXT_FIELD);
|
form_driver(form, REQ_NEXT_FIELD);
|
||||||
form_driver(form, REQ_END_LINE);
|
form_driver(form, REQ_END_LINE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KEY_UP:
|
case KEY_UP:
|
||||||
form_driver(form, REQ_PREV_FIELD);
|
form_driver(form, REQ_PREV_FIELD);
|
||||||
form_driver(form, REQ_END_LINE);
|
form_driver(form, REQ_END_LINE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KEY_LEFT:
|
case KEY_LEFT:
|
||||||
form_driver(form, REQ_PREV_CHAR);
|
form_driver(form, REQ_PREV_CHAR);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KEY_RIGHT:
|
case KEY_RIGHT:
|
||||||
form_driver(form, REQ_NEXT_CHAR);
|
form_driver(form, REQ_NEXT_CHAR);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KEY_BACKSPACE:
|
case KEY_BACKSPACE:
|
||||||
case 127:
|
case 127:
|
||||||
form_driver(form, REQ_DEL_PREV);
|
form_driver(form, REQ_DEL_PREV);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KEY_DC:
|
case KEY_DC:
|
||||||
form_driver(form, REQ_DEL_CHAR);
|
form_driver(form, REQ_DEL_CHAR);
|
||||||
break;
|
break;
|
||||||
case 10: // Enter key
|
|
||||||
case KEY_ENTER: {
|
case 10: // Enter
|
||||||
int idx = field_index(current_field(form));
|
if (field_configs[current_field(form)->index].multiline) {
|
||||||
if (field_info[idx].multiline) {
|
|
||||||
form_driver(form, REQ_NEW_LINE);
|
form_driver(form, REQ_NEW_LINE);
|
||||||
} else {
|
} else {
|
||||||
form_driver(form, REQ_NEXT_FIELD);
|
form_driver(form, REQ_NEXT_FIELD);
|
||||||
form_driver(form, REQ_END_LINE);
|
|
||||||
}
|
}
|
||||||
} break;
|
break;
|
||||||
|
|
||||||
case '\t':
|
case '\t':
|
||||||
form_driver(form, REQ_NEXT_FIELD);
|
form_driver(form, REQ_NEXT_FIELD);
|
||||||
form_driver(form, REQ_END_LINE);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KEY_BTAB:
|
case KEY_BTAB:
|
||||||
form_driver(form, REQ_PREV_FIELD);
|
form_driver(form, REQ_PREV_FIELD);
|
||||||
form_driver(form, REQ_END_LINE);
|
|
||||||
break;
|
|
||||||
case KEY_HOME:
|
|
||||||
form_driver(form, REQ_BEG_LINE);
|
|
||||||
break;
|
|
||||||
case KEY_END:
|
|
||||||
form_driver(form, REQ_END_LINE);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
form_driver(form, ch);
|
form_driver(form, ch);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
wrefresh(win_form);
|
// Ruční aktualizace všech oken
|
||||||
wrefresh(win_body);
|
touchwin(main_win);
|
||||||
|
wrefresh(main_win);
|
||||||
|
wrefresh(label_win);
|
||||||
|
wrefresh(field_win);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validace před čtením dat (důležité pro získání aktuálních hodnot)[1][5]
|
// Získání dat
|
||||||
form_driver(form, REQ_VALIDATION);
|
form_driver(form, REQ_VALIDATION);
|
||||||
|
|
||||||
// Sběr dat z formuláře
|
|
||||||
std::vector<std::string> field_values;
|
std::vector<std::string> field_values;
|
||||||
for (int i = 0; i < NUM_FIELDS; i++) {
|
for (size_t i = 0; i < ARRAY_SIZE(field_configs); i++) {
|
||||||
char *buffer = field_buffer(fields[i], 0);
|
field_values.push_back(trim(field_buffer(fields[i], 0)));
|
||||||
field_values.push_back(trim(buffer));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Uvolnění prostředků
|
// Úklid
|
||||||
unpost_form(form);
|
unpost_form(form);
|
||||||
free_form(form);
|
free_form(form);
|
||||||
for (int i = 0; i < NUM_FIELDS; i++) {
|
for (fieldnode *&f : fields)
|
||||||
free_field(fields[i]);
|
if (f)
|
||||||
}
|
free_field(f);
|
||||||
delwin(win_form);
|
delwin(label_win);
|
||||||
delwin(win_body);
|
delwin(field_win);
|
||||||
endwin();
|
delwin(main_win);
|
||||||
|
curs_set(0);
|
||||||
|
clear();
|
||||||
|
|
||||||
// Aktuální datum
|
// Aktuální datum
|
||||||
std::time_t t = std::time(nullptr);
|
std::time_t t = std::time(nullptr);
|
||||||
@@ -191,63 +212,30 @@
|
|||||||
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 comp_args =
|
||||||
std::string complaint =
|
std::make_format_args(field_values[0], // Jméno a příjmení odesílatele
|
||||||
std::format(R"(
|
field_values[1], // Adresa odesílatele
|
||||||
TRESTNÍ OZNÁMENÍ
|
field_values[2], // Telefon odesílatele
|
||||||
|
field_values[3], // Email odesílatele
|
||||||
|
|
||||||
Policie České republiky
|
field_values[4], // Jméno a příjmení adresáta
|
||||||
Krajské ředitelství policie
|
field_values[5], // Adresa adresáta
|
||||||
Obvodní oddělení
|
field_values[6], // Telefon adresáta
|
||||||
|
field_values[7], // Email adresáta
|
||||||
|
|
||||||
V {} dne {}
|
date_str, // Aktuální datum
|
||||||
|
field_values[8], // Místo činu
|
||||||
|
field_values[9], // Datum činu
|
||||||
|
|
||||||
Oznamovatel:
|
field_values[10], // Popis činu
|
||||||
Jméno a příjmení: {}
|
field_values[11], // Důkazy
|
||||||
Adresa: {}
|
field_values[12], // Další informace
|
||||||
Telefon: {}
|
field_values[0] // Jméno pro podpis
|
||||||
Email: {}
|
|
||||||
|
|
||||||
Věc: Oznámení o skutečnostech nasvědčujících tomu, že byl spáchán trestný čin
|
|
||||||
|
|
||||||
{}
|
|
||||||
|
|
||||||
K trestnému činu došlo dne {} v {}.
|
|
||||||
|
|
||||||
Popis skutku:
|
|
||||||
{}
|
|
||||||
|
|
||||||
Důkazy:
|
|
||||||
{}
|
|
||||||
|
|
||||||
Další informace:
|
|
||||||
{}
|
|
||||||
|
|
||||||
S úctou,
|
|
||||||
|
|
||||||
............................
|
|
||||||
{}
|
|
||||||
(podpis oznamovatele)
|
|
||||||
)",
|
|
||||||
field_values[4], // Místo
|
|
||||||
date_str, // Aktuální datum
|
|
||||||
field_values[0], // Jméno a příjmení
|
|
||||||
field_values[1], // Adresa
|
|
||||||
field_values[2], // Telefon
|
|
||||||
field_values[3], // Email
|
|
||||||
field_values[7].empty()
|
|
||||||
? "Tímto podávám trestní oznámení na neznámého pachatele "
|
|
||||||
"pro podezření ze spáchání trestného činu."
|
|
||||||
: std::format("Tímto podávám trestní oznámení na: {} pro "
|
|
||||||
"podezření ze spáchání trestného činu.",
|
|
||||||
field_values[7]),
|
|
||||||
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
|
|
||||||
);
|
);
|
||||||
noecho();
|
|
||||||
|
std::string complaint =
|
||||||
|
std::vformat(loc_strings->criminal_complaint_template, comp_args);
|
||||||
|
|
||||||
|
delete_all(&editor_easy_allocated);
|
||||||
return complaint;
|
return complaint;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,190 @@
|
|||||||
|
#include "strings.h"
|
||||||
|
#include <cstddef>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <ncurses.h>
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
#include <nlohmann/json_fwd.hpp>
|
||||||
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
using nlohmann::json;
|
||||||
|
|
||||||
|
void save_document(std::string &text, std::vector<std::string> &lines) {
|
||||||
|
text = "";
|
||||||
|
for (const std::string &line : lines) {
|
||||||
|
text.append(line);
|
||||||
|
text.append("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void editor_hard(std::string &text) {
|
||||||
|
uint16_t cursor_x = 0;
|
||||||
|
uint16_t cursor_y = 0;
|
||||||
|
std::vector<std::string> lines;
|
||||||
|
char mode = 'n';
|
||||||
|
uint16_t window_height, window_width;
|
||||||
|
|
||||||
|
mode = 'n';
|
||||||
|
|
||||||
|
noecho();
|
||||||
|
curs_set(1);
|
||||||
|
cbreak();
|
||||||
|
keypad(stdscr, TRUE);
|
||||||
|
getmaxyx(stdscr, window_height, window_width);
|
||||||
|
|
||||||
|
// Parse the multi-line string into individual lines
|
||||||
|
lines.clear();
|
||||||
|
std::stringstream ss(text);
|
||||||
|
std::string line;
|
||||||
|
|
||||||
|
while (std::getline(ss, line)) {
|
||||||
|
lines.push_back(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure at least one empty line exists
|
||||||
|
if (lines.empty()) {
|
||||||
|
lines.push_back("");
|
||||||
|
}
|
||||||
|
while (true) {
|
||||||
|
clear();
|
||||||
|
// Draw text lines
|
||||||
|
for (size_t i = 0;
|
||||||
|
i < static_cast<size_t>(window_height) - 1 && i < lines.size(); i++) {
|
||||||
|
mvprintw(i, 0, "%s", lines[i].c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw status line
|
||||||
|
std::string status = "Mode: " + std::string(1, mode);
|
||||||
|
mvprintw(window_height - 1, 0, "%s", status.c_str());
|
||||||
|
|
||||||
|
move(cursor_y, cursor_x);
|
||||||
|
refresh();
|
||||||
|
{
|
||||||
|
int ch = getch();
|
||||||
|
switch (mode) {
|
||||||
|
case 'n': // Normal mode
|
||||||
|
switch (ch) {
|
||||||
|
case 'h':
|
||||||
|
if (cursor_x > 0) {
|
||||||
|
cursor_x--;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'j':
|
||||||
|
if (cursor_y < lines.size() - 1) {
|
||||||
|
cursor_y++;
|
||||||
|
if (cursor_x > lines[cursor_y].length()) {
|
||||||
|
cursor_x = lines[cursor_y].length();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'k':
|
||||||
|
if (cursor_y > 0) {
|
||||||
|
cursor_y--;
|
||||||
|
if (cursor_x > lines[cursor_y].length()) {
|
||||||
|
cursor_x = lines[cursor_y].length();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 'l':
|
||||||
|
if (cursor_x < lines[cursor_y].length()) {
|
||||||
|
cursor_x++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'i':
|
||||||
|
case 'a':
|
||||||
|
mode = 'i';
|
||||||
|
break;
|
||||||
|
case 'x':
|
||||||
|
if (cursor_x < lines[cursor_y].length()) {
|
||||||
|
lines[cursor_y].erase(cursor_x, 1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ':': {
|
||||||
|
// Enter command mode
|
||||||
|
std::string command = "";
|
||||||
|
int cmd_ch;
|
||||||
|
// Show command prompt
|
||||||
|
mvprintw(window_height - 1, 0, ":%s", command.c_str());
|
||||||
|
clrtoeol();
|
||||||
|
refresh();
|
||||||
|
|
||||||
|
while ((cmd_ch = getch()) != '\n' && cmd_ch != '\r') {
|
||||||
|
if (cmd_ch == 27) { // ESC - cancel command
|
||||||
|
break;
|
||||||
|
} else if (cmd_ch == KEY_BACKSPACE || cmd_ch == 127) {
|
||||||
|
if (!command.empty()) {
|
||||||
|
command.pop_back();
|
||||||
|
}
|
||||||
|
} else if (cmd_ch >= 32 && cmd_ch <= 126) {
|
||||||
|
command += static_cast<char>(cmd_ch);
|
||||||
|
}
|
||||||
|
|
||||||
|
mvprintw(window_height - 1, 0, ":%s", command.c_str());
|
||||||
|
clrtoeol();
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Execute command
|
||||||
|
if (cmd_ch != 27) { // If not cancelled
|
||||||
|
switch (hash_djb2a(command)) {
|
||||||
|
case "q"_sh:
|
||||||
|
return;
|
||||||
|
break;
|
||||||
|
case "w"_sh:
|
||||||
|
save_document(text, lines);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "wq"_sh:
|
||||||
|
case "x"_sh:
|
||||||
|
save_document(text, lines);
|
||||||
|
return;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "q!"_sh:
|
||||||
|
return;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'i': // Insert mode
|
||||||
|
switch (ch) {
|
||||||
|
case 27: // ESC
|
||||||
|
mode = 'n';
|
||||||
|
if (cursor_x > 0)
|
||||||
|
cursor_x--;
|
||||||
|
break;
|
||||||
|
case KEY_BACKSPACE:
|
||||||
|
case 127:
|
||||||
|
if (mode == 'i' && cursor_x > 0) {
|
||||||
|
lines[cursor_y].erase(cursor_x - 1, 1);
|
||||||
|
cursor_x--;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case '\n':
|
||||||
|
case '\r': {
|
||||||
|
// Insert new line
|
||||||
|
std::string new_line = lines[cursor_y].substr(cursor_x);
|
||||||
|
lines[cursor_y] = lines[cursor_y].substr(0, cursor_x);
|
||||||
|
lines.insert(lines.begin() + cursor_y + 1, new_line);
|
||||||
|
cursor_y++;
|
||||||
|
cursor_x = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
if (ch >= 32 && ch <= 126) {
|
||||||
|
if (mode == 'i') {
|
||||||
|
lines[cursor_y].insert(cursor_x, 1, ch);
|
||||||
|
cursor_x++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
#ifndef PARADOCS_EDEH_H_
|
||||||
|
#define PARADOCS_EDEH_H_
|
||||||
|
#include <string>
|
||||||
|
void editor_hard(std::string& text);
|
||||||
|
#endif
|
||||||
+10
-75
@@ -14,76 +14,10 @@
|
|||||||
#include <thread>
|
#include <thread>
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
|
||||||
/*
|
|
||||||
size_t spawn_menu(uint16_t begin_y, uint16_t begin_x, const char** choices,
|
|
||||||
size_t n_choices) {
|
|
||||||
ITEM** sp_items;
|
|
||||||
int c;
|
|
||||||
MENU* sp_menu;
|
|
||||||
WINDOW* sp_menu_win;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
sp_items = new ITEM*[n_choices];
|
|
||||||
// Create items
|
|
||||||
for (i = 0; i < n_choices; ++i) {
|
|
||||||
sp_items[i] = new_item(choices[i], choices[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Crate menu
|
|
||||||
sp_menu = new_menu(sp_items);
|
|
||||||
|
|
||||||
// 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_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(sp_menu, " * ");
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
mvwhline(sp_menu_win, 2, 1, ACS_HLINE, 38);
|
|
||||||
mvwaddch(sp_menu_win, 2, 39, ACS_RTEE);
|
|
||||||
mvprintw(LINES - 2, 0, "F1 to exit");
|
|
||||||
refresh();
|
|
||||||
|
|
||||||
// Post the menu
|
|
||||||
post_menu(sp_menu);
|
|
||||||
wrefresh(sp_menu_win);
|
|
||||||
|
|
||||||
while ((c = wgetch(sp_menu_win)) != 10) {
|
|
||||||
switch (c) {
|
|
||||||
case KEY_DOWN:
|
|
||||||
menu_driver(sp_menu, REQ_DOWN_ITEM);
|
|
||||||
break;
|
|
||||||
case KEY_UP:
|
|
||||||
menu_driver(sp_menu, REQ_UP_ITEM);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
wrefresh(sp_menu_win);
|
|
||||||
}
|
|
||||||
size_t selected = item_index(current_item(sp_menu));
|
|
||||||
|
|
||||||
// Unpost and free all the memory taken up
|
|
||||||
unpost_menu(sp_menu);
|
|
||||||
free_menu(sp_menu);
|
|
||||||
for (i = 0; i < n_choices; ++i)
|
|
||||||
free_item(sp_items[i]);
|
|
||||||
delete[] sp_items;
|
|
||||||
|
|
||||||
return selected;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
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;
|
uint8_t temp;
|
||||||
|
|
||||||
if (win == NULL)
|
if (win == NULL)
|
||||||
win = stdscr;
|
win = stdscr;
|
||||||
@@ -97,14 +31,14 @@ void print_in_middle(WINDOW* win, int starty, int startx, int width,
|
|||||||
|
|
||||||
length = strlen(string);
|
length = strlen(string);
|
||||||
temp = (width - length) / 2;
|
temp = (width - length) / 2;
|
||||||
x = startx + (int)temp;
|
x = startx + temp;
|
||||||
wattron(win, color);
|
wattron(win, color);
|
||||||
mvwprintw(win, y, x, "%s", string);
|
mvwprintw(win, y, x, "%s", string);
|
||||||
wattroff(win, color);
|
wattroff(win, color);
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string spawncmd() {
|
std::string spawncmd(const std::string prompt) {
|
||||||
char cmd[100] = {0};
|
char cmd[100] = {0};
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
int ch;
|
int ch;
|
||||||
@@ -115,7 +49,7 @@ std::string spawncmd() {
|
|||||||
|
|
||||||
keypad(cmd_win, TRUE);
|
keypad(cmd_win, TRUE);
|
||||||
box(cmd_win, 0, 0);
|
box(cmd_win, 0, 0);
|
||||||
mvwprintw(cmd_win, 1, 1, "Command: ");
|
mvwprintw(cmd_win, 1, 1, "%s: ", prompt.c_str());
|
||||||
curs_set(1);
|
curs_set(1);
|
||||||
wrefresh(cmd_win);
|
wrefresh(cmd_win);
|
||||||
|
|
||||||
@@ -133,7 +67,7 @@ std::string spawncmd() {
|
|||||||
if (pos > 0) {
|
if (pos > 0) {
|
||||||
pos--;
|
pos--;
|
||||||
// Move cursor back and erase the character
|
// Move cursor back and erase the character
|
||||||
wmove(cmd_win, 1, 10 + pos);
|
wmove(cmd_win, 1, prompt.length() + 3 + pos);
|
||||||
waddch(cmd_win, ' ');
|
waddch(cmd_win, ' ');
|
||||||
wmove(cmd_win, 1, 10 + pos);
|
wmove(cmd_win, 1, 10 + pos);
|
||||||
}
|
}
|
||||||
@@ -142,7 +76,8 @@ 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, prompt.length() + 3 + pos,
|
||||||
|
ch); // Echo the character
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,11 +138,11 @@ 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});
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#include "strings.h"
|
||||||
#include <ncurses.h>
|
#include <ncurses.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@@ -6,14 +7,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(const std::string prompt = loc_strings->command);
|
||||||
|
|
||||||
void async_clock_init();
|
void async_clock_init();
|
||||||
|
|
||||||
#endif // PARADOCS_GAFU_H_
|
#endif // PARADOCS_GAFU_H_
|
||||||
+38
-20
@@ -1,11 +1,14 @@
|
|||||||
#include <unistd.h>
|
|
||||||
#include <csignal>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <iostream>
|
|
||||||
#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 <csignal>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <iostream>
|
||||||
|
#include <locale>
|
||||||
|
#include <regex>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
void PrintHelp() {
|
void PrintHelp() {
|
||||||
std::cout << RED R"( ____ ____
|
std::cout << RED R"( ____ ____
|
||||||
@@ -15,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);
|
||||||
@@ -37,19 +41,33 @@ int main(int argc, char* argv[]) {
|
|||||||
// error signal handlers
|
// error signal handlers
|
||||||
signal(SIGSEGV, safe_exit);
|
signal(SIGSEGV, safe_exit);
|
||||||
|
|
||||||
|
// set locale
|
||||||
|
{
|
||||||
|
std::locale loc("");
|
||||||
|
std::regex czech_regex("czech|cz", std::regex_constants::icase |
|
||||||
|
std::regex_constants::ECMAScript);
|
||||||
|
|
||||||
|
if (std::regex_search(loc.name(), czech_regex)) {
|
||||||
|
loc_strings = &czech_strings;
|
||||||
|
} else {
|
||||||
|
loc_strings = &english_strings;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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();
|
||||||
|
|||||||
+355
-19
@@ -1,26 +1,144 @@
|
|||||||
|
#include "color.h"
|
||||||
#include "const.h"
|
#include "const.h"
|
||||||
#include "cups.h"
|
#include "cups.h"
|
||||||
#include "editor_easy.h"
|
#include "editor_easy.h"
|
||||||
|
#include "editor_hard.h"
|
||||||
#include "gameske_funkce.h"
|
#include "gameske_funkce.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
#include "signal.h"
|
||||||
|
#include "strings.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include <clocale>
|
#include <array>
|
||||||
|
#include <cerrno>
|
||||||
|
#include <climits>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
#include <cstdint>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <curses.h>
|
#include <curses.h>
|
||||||
|
#include <filesystem>
|
||||||
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
#include <menu.h>
|
#include <menu.h>
|
||||||
#include <ncurses.h>
|
#include <ncurses.h>
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
using nlohmann::json;
|
||||||
|
|
||||||
std::vector<allocation> main_menu_allocated;
|
std::vector<allocation> main_menu_allocated;
|
||||||
|
#define COMPLAINTS_DIR "complaints"
|
||||||
|
|
||||||
const char *choices[] = {"paradox", "kompromis", "Stereotyp", "Žena"};
|
std::array<std::string, 2> get_name_date_from_item(ITEM *item) {
|
||||||
const char *date[] = {"2023-10-01", "2023-10-02", "2023-10-03", "2023-10-04"};
|
std::stringstream ss(item_description(item));
|
||||||
const char *choices2[] = {"PRINT", "EDIT", "DELETE", "Žena"};
|
std::array<std::string, 2> name_date;
|
||||||
|
name_date[0] = item_name(item);
|
||||||
|
std::getline(ss, name_date[1], ' ');
|
||||||
|
return name_date;
|
||||||
|
}
|
||||||
|
|
||||||
|
void reload_menu_from_directory(complete_menu &main_menu) {
|
||||||
|
// Clean up existing menu items and allocated memory
|
||||||
|
if (main_menu.menu != nullptr) {
|
||||||
|
unpost_menu(main_menu.menu);
|
||||||
|
free_menu(main_menu.menu);
|
||||||
|
main_menu.menu = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Free existing menu items
|
||||||
|
if (main_menu.items != nullptr) {
|
||||||
|
for (size_t i = 0; i < main_menu.items_size; i++) {
|
||||||
|
if (main_menu.items[i] != nullptr) {
|
||||||
|
free_item(main_menu.items[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delete[] main_menu.items;
|
||||||
|
main_menu.items = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clean up allocated memory (excluding the complete_menu itself)
|
||||||
|
for (auto it = main_menu_allocated.begin();
|
||||||
|
it != main_menu_allocated.end();) {
|
||||||
|
if (it->type == GENERIC_TYPE) {
|
||||||
|
delete[] static_cast<char *>(it->ptr);
|
||||||
|
it = main_menu_allocated.erase(it);
|
||||||
|
} else {
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recreate items from directory (same logic as initialization)
|
||||||
|
std::vector<ITEM *> items;
|
||||||
|
|
||||||
|
if (std::filesystem::exists(COMPLAINTS_DIR)) {
|
||||||
|
for (const std::filesystem::directory_entry &directroy_entry :
|
||||||
|
std::filesystem::directory_iterator(COMPLAINTS_DIR)) {
|
||||||
|
if (directroy_entry.is_regular_file()) {
|
||||||
|
std::ifstream file(directroy_entry.path());
|
||||||
|
std::string name_date[2];
|
||||||
|
std::stringstream ssfn(directroy_entry.path().filename().string());
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < ARRAY_SIZE(name_date); i++) {
|
||||||
|
std::getline(ssfn, name_date[i], '_');
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
json complaint_json = json::parse(file);
|
||||||
|
|
||||||
|
if (complaint_json["status"].is_null() ||
|
||||||
|
complaint_json["status"].get<uint8_t>() >= STATUS_COUNT) {
|
||||||
|
std::cerr << "Invalid status in file: "
|
||||||
|
<< directroy_entry.path().filename().string()
|
||||||
|
<< std::endl;
|
||||||
|
safe_exit(EINVAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
name_date[1].append(" ");
|
||||||
|
name_date[1].append(
|
||||||
|
loc_strings
|
||||||
|
->status_strings[complaint_json["status"].get<uint8_t>()]);
|
||||||
|
} catch (...) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *name = new char[name_date[0].length() + 1];
|
||||||
|
main_menu_allocated.push_back({GENERIC_TYPE, name, 1});
|
||||||
|
char *date = new char[name_date[1].length() + 1];
|
||||||
|
main_menu_allocated.push_back({GENERIC_TYPE, date, 1});
|
||||||
|
|
||||||
|
strcpy(name, name_date[0].c_str());
|
||||||
|
strcpy(date, name_date[1].c_str());
|
||||||
|
items.push_back(new_item(name, date));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add null terminator
|
||||||
|
items.push_back(nullptr);
|
||||||
|
|
||||||
|
// Create new menu items array
|
||||||
|
main_menu.items = new ITEM *[items.size()];
|
||||||
|
main_menu.items_size = items.size() - 1;
|
||||||
|
memcpy(main_menu.items, items.data(), (items.size() * sizeof(ITEM *)));
|
||||||
|
|
||||||
|
// Create new menu
|
||||||
|
main_menu.menu = new_menu(main_menu.items);
|
||||||
|
|
||||||
|
// Restore menu settings
|
||||||
|
set_menu_win(main_menu.menu, main_menu.win);
|
||||||
|
set_menu_sub(main_menu.menu, derwin(main_menu.win, 6, 38, 3, 1));
|
||||||
|
set_menu_mark(main_menu.menu, " * ");
|
||||||
|
|
||||||
|
// Post the menu
|
||||||
|
post_menu(main_menu.menu);
|
||||||
|
wrefresh(main_menu.win);
|
||||||
|
}
|
||||||
|
|
||||||
void menu() {
|
void menu() {
|
||||||
current_allocated = &main_menu_allocated;
|
current_allocated = &main_menu_allocated;
|
||||||
/* Initialize curses */
|
/* Initialize curses */
|
||||||
|
|
||||||
setlocale(LC_ALL, "");
|
setlocale(LC_ALL, "");
|
||||||
initscr();
|
initscr();
|
||||||
start_color();
|
start_color();
|
||||||
@@ -33,17 +151,55 @@ void menu() {
|
|||||||
}
|
}
|
||||||
async_clock_init();
|
async_clock_init();
|
||||||
|
|
||||||
/* Create items */
|
// Create items
|
||||||
size_t n_choices = ARRAY_SIZE(choices);
|
|
||||||
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});
|
||||||
|
{
|
||||||
|
std::vector<ITEM *> items;
|
||||||
|
if (std::filesystem::exists(COMPLAINTS_DIR)) {
|
||||||
|
for (const std::filesystem::directory_entry &directroy_entry :
|
||||||
|
std::filesystem::directory_iterator(COMPLAINTS_DIR)) {
|
||||||
|
if (directroy_entry.is_regular_file()) {
|
||||||
|
std::ifstream file(directroy_entry.path());
|
||||||
|
std::string name_date[2];
|
||||||
|
std::stringstream ssfn(directroy_entry.path().filename().string());
|
||||||
|
for (uint8_t i = 0; i < ARRAY_SIZE(name_date); i++) {
|
||||||
|
std::getline(ssfn, name_date[i], '_');
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
json complaint_json = json::parse(file);
|
||||||
|
if (complaint_json["status"].is_null() ||
|
||||||
|
complaint_json["status"].get<size_t>() >= STATUS_COUNT) {
|
||||||
|
std::cerr << "Invalid status in file: "
|
||||||
|
<< directroy_entry.path().filename().string()
|
||||||
|
<< std::endl;
|
||||||
|
safe_exit(EINVAL);
|
||||||
|
}
|
||||||
|
name_date[1].append(" ");
|
||||||
|
name_date[1].append(
|
||||||
|
loc_strings
|
||||||
|
->status_strings[complaint_json["status"].get<uint8_t>()]);
|
||||||
|
} catch (...) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
main_menu.items = new ITEM *[ARRAY_SIZE(choices) + 1];
|
char *name = new char[name_date[0].length() + 1];
|
||||||
main_menu.items_size = ARRAY_SIZE(choices) + 1;
|
main_menu_allocated.push_back({GENERIC_TYPE, name, 1});
|
||||||
for (size_t i = 0; i < n_choices; ++i) {
|
char *date = new char[name_date[1].length() + 1];
|
||||||
main_menu.items[i] = new_item(choices[i], date[i]);
|
main_menu_allocated.push_back({GENERIC_TYPE, date, 1});
|
||||||
|
strcpy(name, name_date[0].c_str());
|
||||||
|
strcpy(date, name_date[1].c_str());
|
||||||
|
items.push_back(new_item(name, date));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
std::filesystem::create_directory(COMPLAINTS_DIR);
|
||||||
|
}
|
||||||
|
items.push_back(nullptr);
|
||||||
|
main_menu.items = new ITEM *[items.size()];
|
||||||
|
main_menu.items_size = items.size() - 1;
|
||||||
|
memcpy(main_menu.items, items.data(), (items.size() * sizeof(ITEM *)));
|
||||||
}
|
}
|
||||||
main_menu.items[n_choices] = nullptr;
|
|
||||||
|
|
||||||
/* Crate menu */
|
/* Crate menu */
|
||||||
main_menu.menu = new_menu(main_menu.items);
|
main_menu.menu = new_menu(main_menu.items);
|
||||||
@@ -61,11 +217,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 */
|
||||||
@@ -88,21 +245,200 @@ void menu() {
|
|||||||
case ':':
|
case ':':
|
||||||
switch (hash_djb2a(spawncmd())) {
|
switch (hash_djb2a(spawncmd())) {
|
||||||
case "print"_sh:
|
case "print"_sh:
|
||||||
case "p"_sh:
|
case "p"_sh: {
|
||||||
// DONT FORGET TO PRINT ACTUAL DOCUMENT
|
// DONT FORGET TO PRINT ACTUAL DOCUMENT
|
||||||
printDocument("test");
|
std::array<std::string, 2> name_date =
|
||||||
current_allocated = &main_menu_allocated;
|
get_name_date_from_item(current_item(main_menu.menu));
|
||||||
|
std::ifstream selected_file(COMPLAINTS_DIR "/" + name_date[0] + '_' +
|
||||||
|
name_date[1]);
|
||||||
|
if (!selected_file.is_open()) {
|
||||||
|
std::clog << selected_file.rdstate() << "\n";
|
||||||
|
std::cerr << RED "[ERROR] " RESET << loc_strings->invalid_input
|
||||||
|
<< "\n"
|
||||||
|
<< "File: "
|
||||||
|
<< COMPLAINTS_DIR "/" + name_date[0] + '_' + name_date[1]
|
||||||
|
<< "\n";
|
||||||
|
exit(EINVAL);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
json selected_file_json = json::parse(selected_file);
|
||||||
|
|
||||||
|
printDocument(
|
||||||
|
selected_file_json["complaint_text"].get<std::string>());
|
||||||
|
current_allocated = &main_menu_allocated;
|
||||||
|
} catch (...) {
|
||||||
|
safe_exit(EINVAL);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case "easy_edit"_sh:
|
case "easy_edit"_sh:
|
||||||
case "ee"_sh:
|
case "ee"_sh: {
|
||||||
vytvorTrestniOznameni();
|
const std::string name = spawncmd(loc_strings->reference_name);
|
||||||
|
if (name == "") {
|
||||||
|
print_in_middle(main_menu.win, 10, 0, 40, loc_strings->invalid_input,
|
||||||
|
COLOR_PAIR(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
const time_t current_time = time(nullptr);
|
||||||
|
const tm *local_time = localtime(¤t_time);
|
||||||
|
|
||||||
|
char formatted_date[11];
|
||||||
|
strftime(formatted_date, sizeof(formatted_date), "%d-%m-%Y",
|
||||||
|
local_time);
|
||||||
|
|
||||||
|
std::ofstream complaint_file(COMPLAINTS_DIR "/" + name + "_" +
|
||||||
|
formatted_date);
|
||||||
|
|
||||||
|
const std::string complaint_text = vytvorTrestniOznameni();
|
||||||
|
|
||||||
|
json complaint_json = {{"date", formatted_date},
|
||||||
|
{"status", NOT_SEND},
|
||||||
|
{"complaint_text", complaint_text}};
|
||||||
|
|
||||||
|
complaint_file << complaint_json;
|
||||||
|
complaint_file.close();
|
||||||
|
current_allocated = &main_menu_allocated;
|
||||||
|
reload_menu_from_directory(main_menu);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
case "eh"_sh: {
|
||||||
|
std::array<std::string, 2> name_date =
|
||||||
|
get_name_date_from_item(current_item(main_menu.menu));
|
||||||
|
std::ifstream selected_file(COMPLAINTS_DIR "/" + name_date[0] + '_' +
|
||||||
|
name_date[1]);
|
||||||
|
if (!selected_file.is_open()) {
|
||||||
|
std::clog << selected_file.rdstate() << "\n";
|
||||||
|
std::cerr << RED "[ERROR] " RESET << loc_strings->invalid_input
|
||||||
|
<< "\n"
|
||||||
|
<< "File: "
|
||||||
|
<< COMPLAINTS_DIR "/" + name_date[0] + '_' + name_date[1]
|
||||||
|
<< "\n";
|
||||||
|
exit(EINVAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
json selected_file_json = json::parse(selected_file);
|
||||||
|
selected_file.close();
|
||||||
|
std::string complaint_text =
|
||||||
|
selected_file_json["complaint_text"].get<std::string>();
|
||||||
|
editor_hard(complaint_text);
|
||||||
|
curs_set(0);
|
||||||
|
clear();
|
||||||
|
selected_file_json["complaint_text"] = complaint_text;
|
||||||
|
std::ofstream selected_file_out(COMPLAINTS_DIR "/" + name_date[0] +
|
||||||
|
'_' + name_date[1]);
|
||||||
|
selected_file_out << selected_file_json;
|
||||||
|
selected_file_out.close();
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
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;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case 'm': {
|
||||||
|
int current_item_index = item_index(current_item(main_menu.menu));
|
||||||
|
std::array<std::string, 2> name_date =
|
||||||
|
get_name_date_from_item(current_item(main_menu.menu));
|
||||||
|
|
||||||
|
{
|
||||||
|
uint8_t n = 0;
|
||||||
|
size_t indexes[2] = {ULONG_MAX, ULONG_MAX}; // fix compiler warning
|
||||||
|
for (size_t i = 0; (i < main_menu_allocated.size()); i++) {
|
||||||
|
if (main_menu_allocated[i].ptr ==
|
||||||
|
item_name(current_item(main_menu.menu))) {
|
||||||
|
delete[] static_cast<char *>(main_menu_allocated[i].ptr);
|
||||||
|
indexes[0] = i;
|
||||||
|
n++;
|
||||||
|
} else if (main_menu_allocated[i].ptr ==
|
||||||
|
item_description(current_item(main_menu.menu))) {
|
||||||
|
delete[] static_cast<char *>(main_menu_allocated[i].ptr);
|
||||||
|
indexes[1] = i;
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
if (n >= 2) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (indexes[0] == ULONG_MAX || indexes[1] == ULONG_MAX) {
|
||||||
|
std::cerr << RED "[ERROR]" << RESET " HOW DID THIS EVEN HAPPEN\n";
|
||||||
|
safe_exit(84);
|
||||||
|
}
|
||||||
|
if (indexes[0] > indexes[1]) {
|
||||||
|
std::swap(indexes[0], indexes[1]);
|
||||||
|
}
|
||||||
|
main_menu_allocated.erase(main_menu_allocated.begin() + indexes[1]);
|
||||||
|
main_menu_allocated.erase(main_menu_allocated.begin() + indexes[0]);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::ifstream selected_file(COMPLAINTS_DIR "/" + name_date[0] + '_' +
|
||||||
|
name_date[1]);
|
||||||
|
if (!selected_file.is_open()) {
|
||||||
|
std::clog << selected_file.rdstate() << "\n";
|
||||||
|
std::cerr << RED "[ERROR] " RESET << loc_strings->invalid_input
|
||||||
|
<< "\n"
|
||||||
|
<< "File: "
|
||||||
|
<< COMPLAINTS_DIR "/" + name_date[0] + '_' + name_date[1]
|
||||||
|
<< "\n";
|
||||||
|
exit(EINVAL);
|
||||||
|
}
|
||||||
|
json selected_file_json = json::parse(selected_file);
|
||||||
|
selected_file.close();
|
||||||
|
if (selected_file_json["status"].is_null() ||
|
||||||
|
selected_file_json["status"].get<size_t>() < STATUS_COUNT) {
|
||||||
|
|
||||||
|
(selected_file_json["status"].get<uint8_t>() + 1 >= STATUS_COUNT)
|
||||||
|
? selected_file_json["status"] = NOT_SEND
|
||||||
|
: selected_file_json["status"] =
|
||||||
|
selected_file_json["status"].get<uint8_t>() + 1;
|
||||||
|
|
||||||
|
std::ofstream selected_file(COMPLAINTS_DIR "/" + name_date[0] + '_' +
|
||||||
|
name_date[1]);
|
||||||
|
selected_file << selected_file_json;
|
||||||
|
selected_file.close();
|
||||||
|
} else {
|
||||||
|
std::cerr << RED "[ERROR] " RESET << loc_strings->invalid_input
|
||||||
|
<< "\n";
|
||||||
|
exit(EINVAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
name_date[1].append(" ");
|
||||||
|
name_date[1].append(
|
||||||
|
loc_strings
|
||||||
|
->status_strings[selected_file_json["status"].get<uint8_t>()]);
|
||||||
|
char *date_status = new char[name_date[1].length() + 1];
|
||||||
|
main_menu_allocated.push_back({GENERIC_TYPE, date_status, 1});
|
||||||
|
strlcpy(date_status, name_date[1].c_str(), name_date[1].length() + 1);
|
||||||
|
|
||||||
|
char *name = new char[name_date[0].length() + 1];
|
||||||
|
main_menu_allocated.push_back({GENERIC_TYPE, name, 1});
|
||||||
|
strlcpy(name, name_date[0].c_str(), name_date[0].length() + 1);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < main_menu.items_size; i++) {
|
||||||
|
if (main_menu.items[i] == current_item(main_menu.menu)) {
|
||||||
|
free_item(main_menu.items[i]);
|
||||||
|
main_menu.items[i] = new_item(name, date_status);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
WINDOW *old_win_sub = menu_sub(main_menu.menu);
|
||||||
|
unpost_menu(main_menu.menu);
|
||||||
|
free_menu(main_menu.menu);
|
||||||
|
main_menu.menu = new_menu(main_menu.items);
|
||||||
|
set_menu_win(main_menu.menu, main_menu.win);
|
||||||
|
set_menu_sub(main_menu.menu, old_win_sub);
|
||||||
|
set_menu_format(main_menu.menu, 7, 1);
|
||||||
|
set_menu_mark(main_menu.menu, " * ");
|
||||||
|
set_current_item(main_menu.menu, main_menu.items[current_item_index]);
|
||||||
|
post_menu(main_menu.menu);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
wrefresh(main_menu.win);
|
||||||
|
refresh();
|
||||||
|
redrawwin(main_menu.win);
|
||||||
wrefresh(main_menu.win);
|
wrefresh(main_menu.win);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+21
-21
@@ -1,29 +1,29 @@
|
|||||||
#include <curses.h>
|
|
||||||
#include <csignal>
|
|
||||||
#include <iostream>
|
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
#include <csignal>
|
||||||
|
#include <curses.h>
|
||||||
|
#include <iostream>
|
||||||
void safe_exit(int code) {
|
void safe_exit(int code) {
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case SIGTERM:
|
case SIGTERM:
|
||||||
std::cerr << "\nreceived SIGTERM exiting...\n";
|
std::cerr << "\nreceived SIGTERM exiting...\n";
|
||||||
break;
|
break;
|
||||||
case SIGINT:
|
case SIGINT:
|
||||||
std::cerr << "\nreceived SIGINT exiting...\n";
|
std::cerr << "\nreceived SIGINT exiting...\n";
|
||||||
break;
|
break;
|
||||||
case SIGQUIT:
|
case SIGQUIT:
|
||||||
std::cerr << "\nreceived SIGQUIT exiting...\n";
|
std::cerr << "\nreceived SIGQUIT exiting...\n";
|
||||||
break;
|
break;
|
||||||
case SIGHUP:
|
case SIGHUP:
|
||||||
std::cerr << "\nreceived SIGHUP exiting...\n";
|
std::cerr << "\nreceived SIGHUP exiting...\n";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SIGSEGV:
|
case SIGSEGV:
|
||||||
std::cerr << "\nreceived SIGSEGV(segmentaiton fault) exiting...\nIf this "
|
std::cerr << "\nreceived SIGSEGV(segmentation fault) exiting...\nIf this "
|
||||||
"repeats please report it as a bug\n";
|
"repeats please report it as a bug\n";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
delete_all(current_allocated);
|
delete_all(current_allocated);
|
||||||
echo();
|
echo();
|
||||||
|
|||||||
+161
@@ -0,0 +1,161 @@
|
|||||||
|
#include "strings.h"
|
||||||
|
|
||||||
|
constexpr strings english_strings{
|
||||||
|
.invalid_option = "Invalid option:",
|
||||||
|
.try_str = "try",
|
||||||
|
.usage = "Usage",
|
||||||
|
.options = "OPTIONS",
|
||||||
|
.print_this_help = "Print this help",
|
||||||
|
.print_version = "Print version",
|
||||||
|
.version = "version",
|
||||||
|
.main_menu = "List of complaints",
|
||||||
|
.f1_to_exit = "F1 to exit",
|
||||||
|
.unknown_command = "Unknown command:",
|
||||||
|
.min_terminal_size = "Minimum terminal size: 90x28",
|
||||||
|
.name_of_submiter = "Name of submiter:",
|
||||||
|
.address_of_submiter = "Address of submiter:",
|
||||||
|
.phone_of_submiter = "Phone of submiter:",
|
||||||
|
.email_of_submiter = "Email of submiter:",
|
||||||
|
.name_of_recipient = "Name of recipient:",
|
||||||
|
.address_of_recipient = "Address of recipient:",
|
||||||
|
.phone_of_recipient = "Phone of recipient:",
|
||||||
|
.email_of_recipient = "Email of recipient:",
|
||||||
|
.place_of_incident = "Place of incident:",
|
||||||
|
.date_of_incident = "Date of incident (dd.mm.rrrr):",
|
||||||
|
.description_of_incident = "Description of incident:",
|
||||||
|
.evidence_of_incident = "Evidence of incident:",
|
||||||
|
.additional_info = "Additional info:",
|
||||||
|
.cease_and_desist_entry_of_information =
|
||||||
|
"CEASE AND DESIST - ENTRY OF INFORMATION",
|
||||||
|
.enter_all_information_and_press_f10 =
|
||||||
|
"Enter all information and press F10 to finish",
|
||||||
|
.criminal_complaint_template = R"(
|
||||||
|
CRIMINAL COMPLAINT
|
||||||
|
|
||||||
|
To:
|
||||||
|
Police of the Czech Republic
|
||||||
|
|
||||||
|
Complainant:
|
||||||
|
Name and Surname: {0}
|
||||||
|
Address: {1}
|
||||||
|
Phone: {2}
|
||||||
|
E-mail: {3}
|
||||||
|
|
||||||
|
Accused:
|
||||||
|
Name and Surname: {4}
|
||||||
|
Address: {5}
|
||||||
|
Phone: {6}
|
||||||
|
E-mail: {7}
|
||||||
|
|
||||||
|
Subject:
|
||||||
|
suspicion of committing a criminal offence
|
||||||
|
|
||||||
|
Date of submission of the complaint: {8}
|
||||||
|
|
||||||
|
On {9} at {10}.
|
||||||
|
|
||||||
|
Factual circumstances:
|
||||||
|
{11}
|
||||||
|
|
||||||
|
Evidence:
|
||||||
|
{12}
|
||||||
|
|
||||||
|
Additional information:
|
||||||
|
{13}
|
||||||
|
|
||||||
|
I request the Police of the Czech Republic to:
|
||||||
|
|
||||||
|
take all measures to clarify and investigate the matter,
|
||||||
|
|
||||||
|
interview witnesses and secure evidentiary materials,
|
||||||
|
|
||||||
|
submit a proposal to the public prosecutor.
|
||||||
|
|
||||||
|
Signature of the complainant: {0}
|
||||||
|
|
||||||
|
*This is not a legal document, but only a template for informational purposes. For legal advice, please consult a qualified attorney.*
|
||||||
|
)",
|
||||||
|
.command = "Command",
|
||||||
|
.invalid_input = "Invalid input",
|
||||||
|
.reference_name = "Reference Name",
|
||||||
|
.status_strings = {"Not sent", "Sent", "Rejected", "Accepted"}};
|
||||||
|
|
||||||
|
constexpr strings czech_strings{
|
||||||
|
.invalid_option = "Neplatná volba: ",
|
||||||
|
.try_str = "zkus",
|
||||||
|
.usage = "Použití",
|
||||||
|
.options = "MOŽNOSTI",
|
||||||
|
.print_this_help = "Zobrazit tuto nápovědu",
|
||||||
|
.print_version = "Zobrazit verzi",
|
||||||
|
.version = "verze",
|
||||||
|
.main_menu = "Seznam Oznámení",
|
||||||
|
.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: ",
|
||||||
|
.address_of_submiter = "Adresa podavatele: ",
|
||||||
|
.phone_of_submiter = "Telefon podavatele: ",
|
||||||
|
.email_of_submiter = "Email podavatele: ",
|
||||||
|
.name_of_recipient = "Jméno adresáta: ",
|
||||||
|
.address_of_recipient = "Adresa adresáta: ",
|
||||||
|
.phone_of_recipient = "Telefon adresáta: ",
|
||||||
|
.email_of_recipient = "Email adresáta: ",
|
||||||
|
.place_of_incident = "Místo činu: ",
|
||||||
|
.date_of_incident = "Datum činu (dd.mm.rrrr):",
|
||||||
|
.description_of_incident = "Popis činu:",
|
||||||
|
.evidence_of_incident = "Důkazy:",
|
||||||
|
.additional_info = "Další informace:",
|
||||||
|
.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í",
|
||||||
|
.criminal_complaint_template = R"(
|
||||||
|
TRESTNÍ OZNÁMENÍ
|
||||||
|
|
||||||
|
Komu:
|
||||||
|
Policie ČR
|
||||||
|
|
||||||
|
Oznamovatel:
|
||||||
|
Jméno a příjmení: {0}
|
||||||
|
Adresa: {1}
|
||||||
|
Telefon: {2}
|
||||||
|
E-mail: {3}
|
||||||
|
|
||||||
|
Obviněný:
|
||||||
|
Jméno a příjmení: {4}
|
||||||
|
Adresa: {5}
|
||||||
|
Telefon: {6}
|
||||||
|
E-mail: {7}
|
||||||
|
|
||||||
|
Věc:
|
||||||
|
podezření ze spáchání trestného činu
|
||||||
|
|
||||||
|
Datum podání oznámení: {8}
|
||||||
|
|
||||||
|
Dne {9} v místě {10}.
|
||||||
|
|
||||||
|
1. Skutkové okolnosti:
|
||||||
|
{11}
|
||||||
|
|
||||||
|
2. Důkazy:
|
||||||
|
{12}
|
||||||
|
|
||||||
|
3. Další informace:
|
||||||
|
{13}
|
||||||
|
|
||||||
|
Žá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.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Podpis oznamovatele: {0}
|
||||||
|
|
||||||
|
*Toto není právní dokument, ale pouze vzor pro informativní účely. Pro právní poradenství se obraťte na kvalifikovaného právníka.*
|
||||||
|
)",
|
||||||
|
.command = "Příkaz",
|
||||||
|
.invalid_input = "Neplatný vstup",
|
||||||
|
.reference_name = "Referenční Název",
|
||||||
|
.status_strings = {"Nebylo odesláno", "Odesláno", "Zamítnuto", "Přijato"}};
|
||||||
|
|
||||||
|
const strings *loc_strings;
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
|
||||||
|
#ifndef PARADOCS_STRINGS_H_
|
||||||
|
#define PARADOCS_STRINGS_H_
|
||||||
|
#include "const.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;
|
||||||
|
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* 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* criminal_complaint_template;
|
||||||
|
const char* command;
|
||||||
|
const char* invalid_input;
|
||||||
|
const char* reference_name;
|
||||||
|
const char* status_strings[STATUS_COUNT];
|
||||||
|
} strings;
|
||||||
|
|
||||||
|
extern const strings english_strings;
|
||||||
|
extern const strings czech_strings;
|
||||||
|
extern const strings* loc_strings;
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user