чување dae42a22a79331911b6a9208f824814e73ec4fac
родитељ 5e2d2a94f06895f95f117fe96e43a5a8b1a14fa2
Аутор: Страхиња Радић <sr@strahinja.org>
Датум: Tue, 10 Feb 2026 15:07:26 +0100
Add limit.[ch],poe.h
Diffstat:
| A | limit.c | | | 60 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | limit.h | | | 27 | +++++++++++++++++++++++++++ |
| A | poe.h | | | 80 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
измењених датотека: 3, додавања: 167(+), брисања: 0(-)
diff --git a/limit.c b/limit.c
@@ -0,0 +1,60 @@
+/* This program is licensed under the terms of GNU GPL v3 or (at your option)
+ * any later version. Copyright (C) 2022-2026 Страхиња Радић.
+ * See the file LICENSE for exact copyright and license details. */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "limit.h"
+
+long limits[L_LIMIT_COUNT];
+
+#ifndef LINE_MAX
+#define LINE_MAX _POSIX2_LINE_MAX
+#endif
+
+#ifndef PATH_MAX
+#define PATH_MAX _POSIX_PATH_MAX
+#endif
+
+int
+init_limits(const char* dir)
+{
+ int cwdfd;
+ int result = 0;
+
+ errno = 0;
+
+ if ((cwdfd = open(dir, O_RDONLY)) < 0)
+ return -1;
+
+ limits[L_PATH_MAX] = fpathconf(cwdfd, _PC_PATH_MAX);
+ if (limits[L_PATH_MAX] == -1)
+ {
+ if (errno)
+ {
+ result = -1;
+ goto init_limits_cleanup;
+ }
+ limits[L_PATH_MAX] = PATH_MAX;
+ }
+
+ limits[L_LINE_MAX] = sysconf(_SC_LINE_MAX);
+ if (limits[L_LINE_MAX] == -1)
+ {
+ if (errno)
+ {
+ result = -1;
+ goto init_limits_cleanup;
+ }
+ limits[L_LINE_MAX] = LINE_MAX;
+ }
+
+init_limits_cleanup:
+ close(cwdfd);
+
+ return result;
+}
diff --git a/limit.h b/limit.h
@@ -0,0 +1,27 @@
+/* This program is licensed under the terms of GNU GPL v3 or (at your option)
+ * any later version. Copyright (C) 2022-2026 Страхиња Радић.
+ * See the file LICENSE for exact copyright and license details. */
+
+/* Limits */
+/* clang-format off */
+enum {
+ L_PATH_MAX = 0,
+ L_LINE_MAX = 1,
+ L_LIMIT_COUNT = 2
+};
+/* clang-format on */
+
+extern long limits[];
+
+/* buffer growth factor, in lines */
+#define ALLOC_DELTA 50
+/* line growth factor, in characters */
+#define LINE_ALLOC_DELTA 85
+/* initial line size (not length) */
+#define LINE_DEFAULT 85
+/* maximum size of field in input dialog */
+#define MAXINPUT (512 + 1)
+/* maximum chars for UTF-8 representations of Unicode chars, per Unicode char */
+#define UTF8REPMAX 6
+
+int init_limits(const char* dir);
diff --git a/poe.h b/poe.h
@@ -0,0 +1,80 @@
+/* This program is licensed under the terms of GNU GPL v3 or (at your option)
+ * any later version. Copyright (C) 2021-2026 Страхиња Радић.
+ * See the file LICENSE for exact copyright and license details. */
+
+static int cancel_callback(struct DrawState* state, struct tb_event* ev);
+static int cancel_close(struct DrawState* state);
+static int cancel_msgstr(struct DrawState* state);
+static int cancel_search(struct DrawState* state);
+static int copy_msgid_to_input(struct DrawState* state);
+static int cp(const char* from, const char* to);
+//static int create_file(struct DrawState* state);
+static char* dirname(char* dir, char* path, const ssize_t dir_size);
+static int edit_page_down(struct DrawState* state);
+static int edit_page_up(struct DrawState* state);
+static int erase_backwards(struct DrawState* state);
+static int erase_forward(struct DrawState* state);
+static int erase_prev_word(struct DrawState* state);
+static int erase_search_backwards(struct DrawState* state);
+static int erase_search_forward(struct DrawState* state);
+static int erase_search_prev_word(struct DrawState* state);
+static int erase_search_to_end(struct DrawState* state);
+static int erase_search_to_start(struct DrawState* state);
+static int erase_to_end(struct DrawState* state);
+static int erase_to_start(struct DrawState* state);
+static int exit_program(struct DrawState* state);
+static void goto_msgid(struct DrawState* state, const ssize_t msgid_number);
+static void handle_key_event(struct tb_event* ev, struct DrawState* state);
+static int hide_search(struct DrawState* state);
+static int insert_char(struct DrawState* state, uint32_t ch);
+static int insert_line(struct DrawState* state);
+static void insert_search_char(struct DrawState* state, uint32_t ch);
+static int insert_search_space(struct DrawState* state);
+static int insert_search_tab(struct DrawState* state);
+static int insert_space(struct DrawState* state);
+static int insert_tab(struct DrawState* state);
+static struct DrawState* join_lines(struct DrawState* state, size_t first_line,
+ int forward);
+static struct BufferLine* load_info(struct DrawState* state);
+static struct BufferLine* load_msgstr(struct DrawState* state);
+static int move_down(struct DrawState* state);
+static int move_end(struct DrawState* state);
+static int move_left(struct DrawState* state);
+static int move_list_down(struct DrawState* state);
+static int move_list_end(struct DrawState* state);
+static int move_list_page_down(struct DrawState* state);
+static int move_list_page_up(struct DrawState* state);
+static int move_list_start(struct DrawState* state);
+static int move_list_up(struct DrawState* state);
+static int move_next_word(struct DrawState* state);
+static int move_prev_word(struct DrawState* state);
+static int move_right(struct DrawState* state);
+static int move_search_end(struct DrawState* state);
+static int move_search_left(struct DrawState* state);
+static int move_search_next_word(struct DrawState* state);
+static int move_search_prev_word(struct DrawState* state);
+static int move_search_right(struct DrawState* state);
+static int move_search_start(struct DrawState* state);
+static int move_start(struct DrawState* state);
+static int move_up(struct DrawState* state);
+static int next_fuzzy(struct DrawState* state);
+static int next_match(struct DrawState* state);
+static int next_plural(struct DrawState* state);
+static int next_untranslated(struct DrawState* state);
+static size_t next_msgid(struct DrawState* state, const int delta);
+static int overwrite_copy_msgid_callback(struct DrawState* state, struct tb_event* ev);
+static int overwrite_paste_callback(struct DrawState* state, struct tb_event* ev);
+static int paste_paste_buffer_to_input(struct DrawState* state);
+static int prev_match(struct DrawState* state);
+static size_t prev_msgid(struct DrawState* state, const int delta);
+static int prev_plural(struct DrawState* state);
+int print_error(const int code, const char* msg, ...);
+static int quit_callback(struct DrawState* state, struct tb_event* ev);
+static int save_msgstr(struct DrawState* state);
+static int show_edit(struct DrawState* state);
+static int show_help(struct DrawState* state);
+static int show_search(struct DrawState* state);
+static int toggle_fuzzy(struct DrawState* state);
+static int toggle_info_focused(struct DrawState* state);
+static int yank_input_to_paste_buffer(struct DrawState* state);
+static int write_file(struct DrawState* state);