poe

Уређивач .po фајлова
git clone https://git.sr.ht/~strahinja/poe
Дневник | Датотеке | Референце | ПРОЧИТАЈМЕ | ЛИЦЕНЦА

config.def.h (12016B)


      1 /* This program is licensed under the terms of GNU GPL v3 or (at your option)
      2  * any later version. Copyright (C) 2021-2024  Страхиња Радић.
      3  * See the file LICENSE for exact copyright and license details. */
      4 
      5 /* Comment out to not create backups */
      6 #define CREATE_BACKUPS
      7 
      8 #ifdef PO_C_GLOBALS
      9 const char* backup_suffix = "~";
     10 #endif /* PO_C_GLOBALS */
     11 
     12 /* Correct the ending of msgstr to match msgid if ' ', '.' or '\\n' */
     13 #define MATCH_MSGSTR_ENDING
     14 
     15 /* Uncomment to insert this after Plural-Forms: in the first msgstr (only if
     16  * Plural-Forms isn't already present)
     17  * The plural string given here is for Serbian; adjust to match your language */
     18 /*#define PLURAL_STRING "nplurals=3; plural=(n%10==1 && n%100!=11 ?" \
     19 	" 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);"*/
     20 
     21 #define SAVE_WRAP_WIDTH	  70
     22 #define WRAP_FIRST_MSGSTR 0
     23 #define WARN_COUNT_DOTS	  0
     24 
     25 #define DLG_FG			  TB_BLACK
     26 #define DLG_BG			  TB_WHITE
     27 #define EDIT_MSGID_FG		  TB_BLACK | TB_BOLD
     28 #define EDIT_MSGID_BG		  TB_WHITE
     29 #define EDIT_MSGID_FOCUS_FG	  TB_BLACK
     30 #define EDIT_MSGID_FOCUS_BG	  TB_WHITE
     31 #define EDIT_MSGID_HEADING_FG	  TB_WHITE | TB_BOLD
     32 #define EDIT_MSGID_HEADING_BG	  TB_WHITE
     33 #define EDIT_MSGSTR_FG		  TB_BLACK | TB_BOLD
     34 #define EDIT_MSGSTR_BG		  TB_BLACK
     35 #define EDIT_MSGSTR_FOCUS_FG	  TB_YELLOW | TB_BOLD
     36 #define EDIT_MSGSTR_FOCUS_BG	  TB_BLACK
     37 #define ERROR_FG		  TB_WHITE | TB_BOLD
     38 #define ERROR_BG		  TB_RED
     39 #define FLAG_FG			  TB_YELLOW | TB_BOLD
     40 #define FLAG_BG			  TB_DEFAULT
     41 #define LIST_FLAGS_FG		  TB_YELLOW | TB_BOLD
     42 #define LIST_FLAGS_BG		  TB_DEFAULT
     43 #define LIST_FLAGS_SEL_FG	  TB_WHITE | TB_BOLD
     44 #define LIST_FLAGS_SEL_BG	  TB_BLUE
     45 #define LIST_MSGID_FG		  TB_WHITE
     46 #define LIST_MSGID_BG		  TB_DEFAULT
     47 #define LIST_MSGID_SEL_FG	  TB_WHITE
     48 #define LIST_MSGID_SEL_BG	  TB_BLUE
     49 #define LIST_MSGID_SPECIAL_FG	  TB_YELLOW | TB_BOLD
     50 #define LIST_MSGID_SPECIAL_BG	  TB_DEFAULT
     51 #define LIST_MSGID_SPECIAL_SEL_FG TB_WHITE | TB_BOLD
     52 #define LIST_MSGID_SPECIAL_SEL_BG TB_BLUE
     53 #define LIST_MSGSTR_FG		  TB_GREEN
     54 #define LIST_MSGSTR_BG		  TB_DEFAULT
     55 #define LIST_MSGSTR_SEL_FG	  TB_WHITE | TB_BOLD
     56 #define LIST_MSGSTR_SEL_BG	  TB_BLUE
     57 #define LIST_MSGSTR_WARN_FG	  TB_RED | TB_BOLD
     58 #define LIST_MSGSTR_WARN_BG	  TB_DEFAULT
     59 #define LIST_MSGSTR_SEL_WARN_FG	  TB_RED | TB_BOLD
     60 #define LIST_MSGSTR_SEL_WARN_BG	  TB_BLUE
     61 #define LIST_SEL_FG		  TB_WHITE
     62 #define LIST_SEL_BG		  TB_BLUE
     63 #define MSGID_FG		  TB_GREEN
     64 #define MSGID_BG		  TB_DEFAULT
     65 #define MSGSTR_FG		  TB_WHITE
     66 #define MSGSTR_BG		  TB_DEFAULT
     67 #define PROMPT_FG		  TB_YELLOW | TB_BOLD
     68 #define PROMPT_BG		  TB_MAGENTA
     69 #define SEARCH_FG		  TB_BLACK
     70 #define SEARCH_BG		  TB_WHITE
     71 #define SEARCH_EDIT_FG		  TB_WHITE | TB_BOLD
     72 #define SEARCH_EDIT_BG		  TB_BLACK
     73 #define SEARCH_HL_FG		  TB_WHITE | TB_BOLD
     74 #define SEARCH_HL_BG		  TB_GREEN
     75 #define SHADOW_FG		  TB_BLACK
     76 #define SHADOW_BG		  TB_BLACK | TB_BOLD
     77 #define TITLE_FG		  TB_BLACK
     78 #define TITLE_BG		  TB_WHITE
     79 
     80 #ifdef POE_C_GLOBALS
     81 int cancel_close(struct DrawState* state);
     82 int cancel_msgstr(struct DrawState* state);
     83 int cancel_search(struct DrawState* state);
     84 int copy_msgid_to_input(struct DrawState* state);
     85 int edit_page_down(struct DrawState* state);
     86 int edit_page_up(struct DrawState* state);
     87 int erase_backwards(struct DrawState* state);
     88 int erase_forward(struct DrawState* state);
     89 int erase_prev_word(struct DrawState* state);
     90 int erase_search_backwards(struct DrawState* state);
     91 int erase_search_forward(struct DrawState* state);
     92 int erase_search_prev_word(struct DrawState* state);
     93 int erase_search_to_end(struct DrawState* state);
     94 int erase_search_to_start(struct DrawState* state);
     95 int erase_to_end(struct DrawState* state);
     96 int erase_to_start(struct DrawState* state);
     97 int exit_program(struct DrawState* state);
     98 int hide_search(struct DrawState* state);
     99 int insert_line(struct DrawState* state);
    100 int insert_search_space(struct DrawState* state);
    101 int insert_search_tab(struct DrawState* state);
    102 int insert_space(struct DrawState* state);
    103 int insert_tab(struct DrawState* state);
    104 int move_end(struct DrawState* state);
    105 int move_down(struct DrawState* state);
    106 int move_left(struct DrawState* state);
    107 int move_list_down(struct DrawState* state);
    108 int move_list_end(struct DrawState* state);
    109 int move_list_page_down(struct DrawState* state);
    110 int move_list_page_up(struct DrawState* state);
    111 int move_list_start(struct DrawState* state);
    112 int move_list_up(struct DrawState* state);
    113 int move_next_word(struct DrawState* state);
    114 int move_prev_word(struct DrawState* state);
    115 int move_right(struct DrawState* state);
    116 int move_search_end(struct DrawState* state);
    117 int move_search_left(struct DrawState* state);
    118 int move_search_next_word(struct DrawState* state);
    119 int move_search_prev_word(struct DrawState* state);
    120 int move_search_right(struct DrawState* state);
    121 int move_search_start(struct DrawState* state);
    122 int move_start(struct DrawState* state);
    123 int move_up(struct DrawState* state);
    124 int next_fuzzy(struct DrawState* state);
    125 int next_match(struct DrawState* state);
    126 int next_plural(struct DrawState* state);
    127 int next_untranslated(struct DrawState* state);
    128 int paste_paste_buffer_to_input(struct DrawState* state);
    129 int prev_match(struct DrawState* state);
    130 int prev_plural(struct DrawState* state);
    131 int save_msgstr(struct DrawState* state);
    132 int show_edit(struct DrawState* state);
    133 int show_help(struct DrawState* state);
    134 int show_search(struct DrawState* state);
    135 int toggle_fuzzy(struct DrawState* state);
    136 int toggle_info_focused(struct DrawState* state);
    137 int yank_input_to_paste_buffer(struct DrawState* state);
    138 int write_file(struct DrawState* state);
    139 
    140 /* clang-format off */
    141 
    142 /* Always processed */
    143 static const struct Key top_level_keys[] = {
    144 	{ .ev = { .key = TB_KEY_ESC },  .callback = cancel_close },
    145 	{ .ev = { .key = TB_KEY_CTRL_Q },
    146 					.callback = exit_program },
    147 };
    148 
    149 /* Edit msgstr box open */
    150 static const struct Key edit_keys[] = {
    151 	{ .ev = { .key = TB_KEY_ARROW_DOWN },
    152 					.callback = move_down },
    153 	{ .ev = { .key = TB_KEY_ARROW_LEFT },
    154 					.callback = move_left },
    155 	{ .ev = { .key = TB_KEY_ARROW_RIGHT },
    156 					.callback = move_right },
    157 	{ .ev = { .key = TB_KEY_ARROW_UP },
    158 					.callback = move_up },
    159 	{ .ev = { .key = TB_KEY_BACKSPACE },
    160 					.callback = erase_backwards },
    161 	{ .ev = { .key = TB_KEY_BACKSPACE2 },
    162 					.callback = erase_backwards },
    163 	{ .ev = { .key = TB_KEY_CTRL_A },
    164 					.callback = move_start },
    165 	{ .ev = { .key = TB_KEY_CTRL_C },
    166 					.callback = yank_input_to_paste_buffer },
    167 	{ .ev = { .key = TB_KEY_CTRL_E },
    168 					.callback = move_end },
    169 	{ .ev = { .key = TB_KEY_CTRL_K },
    170 					.callback = erase_to_end },
    171 	{ .ev = { .key = TB_KEY_CTRL_N },
    172 					.callback = next_plural },
    173 	{ .ev = { .key = TB_KEY_CTRL_P },
    174 					.callback = prev_plural },
    175 	{ .ev = { .key = TB_KEY_CTRL_R },
    176 					.callback = move_prev_word },
    177 	{ .ev = { .key = TB_KEY_CTRL_S },
    178 					.callback = save_msgstr },
    179 	{ .ev = { .key = TB_KEY_CTRL_T },
    180 					.callback = move_next_word },
    181 	{ .ev = { .key = TB_KEY_CTRL_U },
    182 					.callback = erase_to_start },
    183 	{ .ev = { .key = TB_KEY_CTRL_V },
    184 					.callback = paste_paste_buffer_to_input },
    185 	{ .ev = { .key = TB_KEY_CTRL_W },
    186 					.callback = erase_prev_word },
    187 	{ .ev = { .key = TB_KEY_CTRL_Z },
    188 					.callback = toggle_fuzzy },
    189 	{ .ev = { .key = TB_KEY_DELETE },
    190 					.callback = erase_forward },
    191 	{ .ev = { .key = TB_KEY_END },	.callback = move_end },
    192 	{ .ev = { .key = TB_KEY_ENTER },
    193 					.callback = insert_line },
    194 	{ .ev = { .key = TB_KEY_F5 },	.callback = copy_msgid_to_input },
    195 	{ .ev = { .key = TB_KEY_F6 },	.callback = toggle_info_focused },
    196 	{ .ev = { .key = TB_KEY_F8 },	.callback = next_untranslated },
    197 	{ .ev = { .key = TB_KEY_F9 },	.callback = next_fuzzy },
    198 	{ .ev = { .key = TB_KEY_HOME },	.callback = move_start },
    199 	{ .ev = { .key = TB_KEY_PGDN },	.callback = edit_page_down },
    200 	{ .ev = { .key = TB_KEY_PGUP },	.callback = edit_page_up },
    201 	{ .ev = { .key = TB_KEY_SPACE },
    202 					.callback = insert_space },
    203 	{ .ev = { .key = TB_KEY_TAB },	.callback = insert_tab },
    204 };
    205 
    206 /* Search box open */
    207 static const struct Key search_keys[] = {
    208 	{ .ev = { .key = TB_KEY_ARROW_LEFT },
    209 					.callback = move_search_left },
    210 	{ .ev = { .key = TB_KEY_ARROW_RIGHT },
    211 					.callback = move_search_right },
    212 	{ .ev = { .key = TB_KEY_BACKSPACE },
    213 					.callback = erase_search_backwards },
    214 	{ .ev = { .key = TB_KEY_BACKSPACE2 },
    215 					.callback = erase_search_backwards },
    216 	{ .ev = { .key = TB_KEY_CTRL_A },
    217 					.callback = move_search_start },
    218 	{ .ev = { .key = TB_KEY_CTRL_E },
    219 					.callback = move_search_end },
    220 	{ .ev = { .key = TB_KEY_CTRL_K },
    221 					.callback = erase_search_to_end },
    222 	{ .ev = { .key = TB_KEY_CTRL_R },
    223 					.callback = move_search_prev_word },
    224 	{ .ev = { .key = TB_KEY_CTRL_S },
    225 					.callback = write_file },
    226 	{ .ev = { .key = TB_KEY_CTRL_T },
    227 					.callback = move_search_next_word },
    228 	{ .ev = { .key = TB_KEY_CTRL_U },
    229 					.callback = erase_search_to_start },
    230 	{ .ev = { .key = TB_KEY_CTRL_W },
    231 					.callback = erase_search_prev_word },
    232 	{ .ev = { .key = TB_KEY_DELETE },
    233 					.callback = erase_search_forward },
    234 	{ .ev = { .key = TB_KEY_END },	.callback = move_search_end },
    235 	{ .ev = { .key = TB_KEY_ENTER },
    236 					.callback = hide_search },
    237 	{ .ev = { .key = TB_KEY_F3 },	.callback = next_match },
    238 	{ .ev = { .key = TB_KEY_F4 },	.callback = prev_match },
    239 	{ .ev = { .key = TB_KEY_HOME },	.callback = move_search_start },
    240 	{ .ev = { .key = TB_KEY_SPACE },
    241 					.callback = insert_search_space },
    242 	{ .ev = { .key = TB_KEY_TAB },	.callback = insert_search_tab },
    243 };
    244 
    245 /* Main window */
    246 static const struct Key main_keys[] = {
    247 	{ .ev = { .key = TB_KEY_ARROW_DOWN },
    248 					.callback = move_list_down },
    249 	{ .ev = { .key = TB_KEY_ARROW_UP },
    250 					.callback = move_list_up },
    251 	{ .ev = { .key = TB_KEY_END },
    252 					.callback = move_list_end },
    253 	{ .ev = { .key = TB_KEY_ENTER },
    254 					.callback = show_edit },
    255 	{ .ev = { .key = TB_KEY_F1 },	.callback = show_help },
    256 	{ .ev = { .key = TB_KEY_F3 },	.callback = next_match },
    257 	{ .ev = { .key = TB_KEY_F4 },	.callback = prev_match },
    258 	{ .ev = { .key = TB_KEY_F7 },	.callback = show_search },
    259 	{ .ev = { .key = TB_KEY_F8 },	.callback = next_untranslated },
    260 	{ .ev = { .key = TB_KEY_F9 },	.callback = next_fuzzy },
    261 	{ .ev = { .key = TB_KEY_HOME },	.callback = move_list_start },
    262 	{ .ev = { .key = TB_KEY_CTRL_B },
    263 					.callback = move_list_page_up },
    264 	{ .ev = { .key = TB_KEY_CTRL_F },
    265 					.callback = move_list_page_down },
    266 	{ .ev = { .key = TB_KEY_CTRL_S },
    267 					.callback = write_file },
    268 	{ .ev = { .key = TB_KEY_CTRL_Z },
    269 					.callback = toggle_fuzzy },
    270 	{ .ev = { .key = TB_KEY_PGDN },
    271 					.callback = move_list_page_down },
    272 	{ .ev = { .key = TB_KEY_PGUP },	.callback = move_list_page_up },
    273 	{ .ev = { .ch = '/' },		.callback = show_search },
    274 	{ .ev = { .ch = 'G' },		.callback = move_list_end },
    275 	{ .ev = { .ch = 'H' },		.callback = show_help },
    276 	{ .ev = { .ch = 'f' },		.callback = next_fuzzy },
    277 	{ .ev = { .ch = 'g' },		.callback = move_list_start },
    278 	{ .ev = { .ch = 'j' },		.callback = move_list_down },
    279 	{ .ev = { .ch = 'k' },		.callback = move_list_up },
    280 	{ .ev = { .ch = 'N' },		.callback = prev_match },
    281 	{ .ev = { .ch = 'n' },		.callback = next_match },
    282 	{ .ev = { .ch = 'q' },		.callback = exit_program },
    283 	{ .ev = { .ch = 'u' },		.callback = next_untranslated },
    284 	{ .ev = { .ch = 'w' },		.callback = write_file },
    285 	{ .ev = { .ch = 'z' },		.callback = toggle_fuzzy },
    286 };
    287 
    288 #endif /* POE_C_GLOBALS */
    289 
    290 void format_filename(char* result, size_t result_size, const char* format,
    291 	const struct DrawState* state);
    292 void format_msgs(char* result, size_t result_size, const char* format,
    293 	const struct DrawState* state);
    294 
    295 static const struct StatusSegment status_segments[] = {
    296 	{.format	   = "%s%s",
    297 		.callback  = format_filename,
    298 		.fg	   = TB_BLACK,
    299 		.bg	   = TB_WHITE,
    300 		.alignment = LEFT},
    301 	{.format	   = "%ld/%ld (%ldu/%ldf/%ldo)",
    302 		.callback  = format_msgs,
    303 		.fg	   = TB_WHITE | TB_BOLD,
    304 		.bg	   = TB_BLUE,
    305 		.alignment = CENTER},
    306 	{.format	   = "H=HELP, q=QUIT",
    307 		.callback  = NULL,
    308 		.fg	   = TB_BLACK,
    309 		.bg	   = TB_WHITE,
    310 		.alignment = RIGHT},
    311 };