poe

Уређивач .po фајлова
Дневник | Датотеке | Референце | ПРОЧИТАЈМЕ | ЛИЦЕНЦА

чување efcfcb1c83d5cd3a14985846362387cced877ac3
родитељ ab74dec9c20884e8561821224d7a8ed3936a2f81
Аутор: Страхиња Радић <contact@strahinja.org>
Датум:   Sun, 11 Jul 2021 21:54:44 +0200

Fix: improved error reporting on first message; disallowed toggle fuzzy and copy msgid to msgstr on first message

Signed-off-by: Страхиња Радић <contact@strahinja.org>

Diffstat:
Mdraw.c | 3++-
Mpoe.c | 14++++++++++++--
Mutil.h | 3++-
измењених датотека: 3, додавања: 16(+), брисања: 4(-)

diff --git a/draw.c b/draw.c @@ -42,7 +42,8 @@ const char* errors[] = { [ERR_EMPTY_FILE] = "No msgids to edit", [ERR_CANT_ALLOC] = "Memory allocation failed", [ERR_CANT_SAVE] = "File is not writeable", - [ERR_CANT_MOVE] = "Cannot move temporary file" + [ERR_CANT_MOVE] = "Cannot move temporary file", + [ERR_ILLEGAL_ON_FIRST] = "Not allowed on first entry" }; const char* flag_strings[] = { [FL_C_FORMAT] = "c-format", diff --git a/poe.c b/poe.c @@ -782,7 +782,12 @@ erase_search_prev_word(struct DrawState* state) struct DrawState* copy_msgid_to_input(struct DrawState* state) { - if (state->edit_info_focused || state->msgid_number == 1) + if (state->msgid_number == 1) + { + strcpy(state->error, errors[ERR_ILLEGAL_ON_FIRST]); + return NULL; + } + if (state->edit_info_focused) return state; struct PoEntry* current = &state->entries[state->msgid_number-1]; size_t msgid_num_lines = u32_lines_in_string(current->msgid); @@ -1408,6 +1413,11 @@ prev_plural(struct DrawState* state) void toggle_fuzzy(struct DrawState* state) { + if (state->msgid_number == 1) + { + strcpy(state->error, errors[ERR_ILLEGAL_ON_FIRST]); + return; + } if (state->msgid_count > 0) { state->entries[state->msgid_number-1].flags ^= FL_FUZZY; @@ -1755,7 +1765,7 @@ handle_key_event(struct tb_event* ev, struct DrawState* state) { if (state->error[0]) state->error[0] = 0; - if (state->in_prompt) + else if (state->in_prompt) { state->in_prompt = 0; state->prompt[0] = 0; diff --git a/util.h b/util.h @@ -13,7 +13,8 @@ enum { ERR_EMPTY_FILE, ERR_CANT_ALLOC, ERR_CANT_SAVE, - ERR_CANT_MOVE + ERR_CANT_MOVE, + ERR_ILLEGAL_ON_FIRST }; #define MAXBUFLINE 4096