poe

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

чување 770e59f4ccd8c98180d611dc0f5b0974d1edc9e5
родитељ ca252ffb38a077f73634c261d2982e511fb823ac
Аутор: Страхиња Радић <contact@strahinja.org>
Датум:   Mon, 14 Jun 2021 17:04:34 +0200

Added fuzzy flag toggle and display of fuzzy flags in status line

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

Diffstat:
Mconfig.def.h | 5+++--
Mconfig.h | 5+++--
Mdraw.c | 1+
Mpoe.c | 16+++++++++++++++-
измењених датотека: 4, додавања: 22(+), брисања: 5(-)

diff --git a/config.def.h b/config.def.h @@ -11,7 +11,7 @@ #define FLAG_BG TB_DEFAULT #define LIST_FLAGS_FG TB_YELLOW | TB_BOLD #define LIST_FLAGS_BG TB_DEFAULT -#define LIST_FLAGS_SEL_FG TB_WHITE +#define LIST_FLAGS_SEL_FG TB_WHITE | TB_BOLD #define LIST_FLAGS_SEL_BG TB_BLUE #define LIST_MSGID_FG TB_WHITE #define LIST_MSGID_BG TB_DEFAULT @@ -38,7 +38,8 @@ void format_msgs(char* result, size_t result_size, const char* format, static const struct StatusSegment status_segments[] = { { .format = "%s", .callback = format_filename, .fg = TB_BLACK, .bg = TB_WHITE, .alignment = LEFT }, - { .format = "msg:%ld/%ld", .callback = format_msgs, + { .format = "msg:%ld/%ld (%ld fuzzy)", + .callback = format_msgs, .fg = TB_WHITE | TB_BOLD, .bg = TB_BLUE, .alignment = CENTER }, { .format = "H=HELP, q=QUIT", .callback = NULL, .fg = TB_BLACK, .bg = TB_WHITE, .alignment = RIGHT }, diff --git a/config.h b/config.h @@ -11,7 +11,7 @@ #define FLAG_BG TB_DEFAULT #define LIST_FLAGS_FG TB_YELLOW | TB_BOLD #define LIST_FLAGS_BG TB_DEFAULT -#define LIST_FLAGS_SEL_FG TB_WHITE +#define LIST_FLAGS_SEL_FG TB_WHITE | TB_BOLD #define LIST_FLAGS_SEL_BG TB_BLUE #define LIST_MSGID_FG TB_WHITE #define LIST_MSGID_BG TB_DEFAULT @@ -38,7 +38,8 @@ void format_msgs(char* result, size_t result_size, const char* format, static const struct StatusSegment status_segments[] = { { .format = "%s", .callback = format_filename, .fg = TB_BLACK, .bg = TB_WHITE, .alignment = LEFT }, - { .format = "msg:%ld/%ld", .callback = format_msgs, + { .format = "msg:%ld/%ld (%ld fuzzy)", + .callback = format_msgs, .fg = TB_WHITE | TB_BOLD, .bg = TB_BLUE, .alignment = CENTER }, { .format = "H=HELP, q=QUIT", .callback = NULL, .fg = TB_BLACK, .bg = TB_WHITE, .alignment = RIGHT }, diff --git a/draw.c b/draw.c @@ -19,6 +19,7 @@ static const char* help[] = { "k or \u2191 - Previous entry", "j or \u2193 - Next entry", "G or End - Last entry", + "f or C-F - Toggle fuzzy flag", "q or C-Q - Quit" }; static const char* editbox_title = "Edit translation"; diff --git a/poe.c b/poe.c @@ -47,12 +47,20 @@ void format_msgs(char* result, size_t result_size, const char* format, const struct DrawState* state) { + int fuzzy_count = 0; + if (!result) return; + if (state && state->msgid_count) + for (size_t i = 0; i < state->msgid_count; i++) + if (state->entries[i].flags & FL_FUZZY) + fuzzy_count++; + snprintf(result, result_size, format, state ? state->msgid_number : 0, - state ? state->msgid_count : 0); + state ? state->msgid_count : 0, + fuzzy_count); } void @@ -97,6 +105,12 @@ handle_key_event(const struct tb_event* ev, struct DrawState* state) state->error[0] = 0; } } + else if (ev->key == TB_KEY_CTRL_F + || (ev->ch == 'f' && !state->show_edit)) + { + if (state->msgid_count > 0) + state->entries[state->msgid_number-1].flags ^= FL_FUZZY; + } else if (ev->key == TB_KEY_HOME || ev->ch == 'g') {