~strahinja/poe

ref: v1.4.7 poe/config.h -rw-r--r-- 11.2 KiB
127f482cСтрахиња Радић po.c: Add licensing comment 9 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
/* See the file LICENSE for copyright and license details. */

/* Comment out to not create backups */
#define CREATE_BACKUPS

#ifdef PO_C_GLOBALS
static const char* backup_suffix = "~";
#endif /* PO_C_GLOBALS */

#define SAVE_WRAP_WIDTH	  70
#define WRAP_FIRST_MSGSTR 0
#define WARN_COUNT_DOTS	  0

#define DLG_FG			  TB_BLACK
#define DLG_BG			  TB_WHITE
#define EDIT_MSGID_FG		  TB_BLACK | TB_BOLD
#define EDIT_MSGID_BG		  TB_WHITE
#define EDIT_MSGID_FOCUS_FG	  TB_BLACK
#define EDIT_MSGID_FOCUS_BG	  TB_WHITE
#define EDIT_MSGID_HEADING_FG	  TB_WHITE | TB_BOLD
#define EDIT_MSGID_HEADING_BG	  TB_WHITE
#define EDIT_MSGSTR_FG		  TB_BLACK | TB_BOLD
#define EDIT_MSGSTR_BG		  TB_BLACK
#define EDIT_MSGSTR_FOCUS_FG	  TB_YELLOW | TB_BOLD
#define EDIT_MSGSTR_FOCUS_BG	  TB_BLACK
#define ERROR_FG		  TB_WHITE | TB_BOLD
#define ERROR_BG		  TB_RED
#define FLAG_FG			  TB_YELLOW | TB_BOLD
#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 | TB_BOLD
#define LIST_FLAGS_SEL_BG	  TB_BLUE
#define LIST_MSGID_FG		  TB_WHITE
#define LIST_MSGID_BG		  TB_DEFAULT
#define LIST_MSGID_SEL_FG	  TB_WHITE
#define LIST_MSGID_SEL_BG	  TB_BLUE
#define LIST_MSGID_SPECIAL_FG	  TB_YELLOW | TB_BOLD
#define LIST_MSGID_SPECIAL_BG	  TB_DEFAULT
#define LIST_MSGID_SPECIAL_SEL_FG TB_WHITE | TB_BOLD
#define LIST_MSGID_SPECIAL_SEL_BG TB_BLUE
#define LIST_MSGSTR_FG		  TB_GREEN
#define LIST_MSGSTR_BG		  TB_DEFAULT
#define LIST_MSGSTR_SEL_FG	  TB_WHITE | TB_BOLD
#define LIST_MSGSTR_SEL_BG	  TB_BLUE
#define LIST_MSGSTR_WARN_FG	  TB_RED | TB_BOLD
#define LIST_MSGSTR_WARN_BG	  TB_DEFAULT
#define LIST_MSGSTR_SEL_WARN_FG	  TB_RED | TB_BOLD
#define LIST_MSGSTR_SEL_WARN_BG	  TB_BLUE
#define LIST_SEL_FG		  TB_WHITE
#define LIST_SEL_BG		  TB_BLUE
#define MSGID_FG		  TB_GREEN
#define MSGID_BG		  TB_DEFAULT
#define MSGSTR_FG		  TB_WHITE
#define MSGSTR_BG		  TB_DEFAULT
#define PROMPT_FG		  TB_YELLOW | TB_BOLD
#define PROMPT_BG		  TB_MAGENTA
#define SEARCH_FG		  TB_BLACK
#define SEARCH_BG		  TB_WHITE
#define SEARCH_EDIT_FG		  TB_WHITE | TB_BOLD
#define SEARCH_EDIT_BG		  TB_BLACK
#define SEARCH_HL_FG		  TB_WHITE | TB_BOLD
#define SEARCH_HL_BG		  TB_GREEN
#define SHADOW_FG		  TB_BLACK
#define SHADOW_BG		  TB_BLACK | TB_BOLD
#define TITLE_FG		  TB_BLACK
#define TITLE_BG		  TB_WHITE

#ifdef POE_C_GLOBALS
int cancel_close(struct DrawState* state);
int cancel_msgstr(struct DrawState* state);
int cancel_search(struct DrawState* state);
int copy_msgid_to_input(struct DrawState* state);
int edit_page_up(struct DrawState* state);
int edit_page_down(struct DrawState* state);
int erase_backwards(struct DrawState* state);
int erase_forward(struct DrawState* state);
int erase_prev_word(struct DrawState* state);
int erase_search_backwards(struct DrawState* state);
int erase_search_forward(struct DrawState* state);
int erase_search_prev_word(struct DrawState* state);
int erase_search_to_start(struct DrawState* state);
int erase_search_to_end(struct DrawState* state);
int erase_to_end(struct DrawState* state);
int erase_to_start(struct DrawState* state);
int exit_program(struct DrawState* state);
int hide_search(struct DrawState* state);
int insert_line(struct DrawState* state);
int insert_search_space(struct DrawState* state);
int insert_search_tab(struct DrawState* state);
int insert_space(struct DrawState* state);
int insert_tab(struct DrawState* state);
int move_end(struct DrawState* state);
int move_down(struct DrawState* state);
int move_left(struct DrawState* state);
int move_list_down(struct DrawState* state);
int move_list_end(struct DrawState* state);
int move_list_page_down(struct DrawState* state);
int move_list_page_up(struct DrawState* state);
int move_list_start(struct DrawState* state);
int move_list_up(struct DrawState* state);
int move_next_word(struct DrawState* state);
int move_prev_word(struct DrawState* state);
int move_right(struct DrawState* state);
int move_search_end(struct DrawState* state);
int move_search_left(struct DrawState* state);
int move_search_next_word(struct DrawState* state);
int move_search_prev_word(struct DrawState* state);
int move_search_right(struct DrawState* state);
int move_search_start(struct DrawState* state);
int move_start(struct DrawState* state);
int move_up(struct DrawState* state);
int next_fuzzy(struct DrawState* state);
int next_match(struct DrawState* state);
int next_plural(struct DrawState* state);
int next_untranslated(struct DrawState* state);
int paste_paste_buffer_to_input(struct DrawState* state);
int prev_match(struct DrawState* state);
int prev_plural(struct DrawState* state);
int save_msgstr(struct DrawState* state);
int show_edit(struct DrawState* state);
int show_help(struct DrawState* state);
int show_search(struct DrawState* state);
int toggle_fuzzy(struct DrawState* state);
int toggle_info_focused(struct DrawState* state);
int yank_msgstr_to_paste_buffer(struct DrawState* state);
int write_file(struct DrawState* state);

/* clang-format off */

/* Always processed */
static const struct Key top_level_keys[] = {
	{ .ev = { .key = TB_KEY_ESC },  .callback = cancel_close },
	{ .ev = { .key = TB_KEY_CTRL_Q },
					.callback = exit_program },
};

/* Edit msgstr box open */
static const struct Key edit_keys[] = {
	{ .ev = { .key = TB_KEY_ARROW_DOWN },
					.callback = move_down },
	{ .ev = { .key = TB_KEY_ARROW_LEFT },
					.callback = move_left },
	{ .ev = { .key = TB_KEY_ARROW_RIGHT },
					.callback = move_right },
	{ .ev = { .key = TB_KEY_ARROW_UP },
					.callback = move_up },
	{ .ev = { .key = TB_KEY_BACKSPACE },
					.callback = erase_backwards },
	{ .ev = { .key = TB_KEY_BACKSPACE2 },
					.callback = erase_backwards },
	{ .ev = { .key = TB_KEY_CTRL_A },
					.callback = move_start },
	{ .ev = { .key = TB_KEY_CTRL_C },
					.callback = yank_msgstr_to_paste_buffer },
	{ .ev = { .key = TB_KEY_CTRL_E },
					.callback = move_end },
	{ .ev = { .key = TB_KEY_CTRL_K },
					.callback = erase_to_end },
	{ .ev = { .key = TB_KEY_CTRL_N },
					.callback = next_plural },
	{ .ev = { .key = TB_KEY_CTRL_P },
					.callback = prev_plural },
	{ .ev = { .key = TB_KEY_CTRL_R },
					.callback = move_prev_word },
	{ .ev = { .key = TB_KEY_CTRL_S },
					.callback = save_msgstr },
	{ .ev = { .key = TB_KEY_CTRL_T },
					.callback = move_next_word },
	{ .ev = { .key = TB_KEY_CTRL_U },
					.callback = erase_to_start },
	{ .ev = { .key = TB_KEY_CTRL_V },
					.callback = paste_paste_buffer_to_input },
	{ .ev = { .key = TB_KEY_CTRL_W },
					.callback = erase_prev_word },
	{ .ev = { .key = TB_KEY_CTRL_Z },
					.callback = toggle_fuzzy },
	{ .ev = { .key = TB_KEY_DELETE },
					.callback = erase_forward },
	{ .ev = { .key = TB_KEY_END },	.callback = move_end },
	{ .ev = { .key = TB_KEY_ENTER },
					.callback = insert_line },
	{ .ev = { .key = TB_KEY_F5 },	.callback = copy_msgid_to_input },
	{ .ev = { .key = TB_KEY_F6 },	.callback = toggle_info_focused },
	{ .ev = { .key = TB_KEY_F8 },	.callback = next_untranslated },
	{ .ev = { .key = TB_KEY_F9 },	.callback = next_fuzzy },
	{ .ev = { .key = TB_KEY_HOME },	.callback = move_start },
	{ .ev = { .key = TB_KEY_PGDN },	.callback = edit_page_down },
	{ .ev = { .key = TB_KEY_PGUP },	.callback = edit_page_up },
	{ .ev = { .key = TB_KEY_SPACE },
					.callback = insert_space },
	{ .ev = { .key = TB_KEY_TAB },	.callback = insert_tab },
};

/* Search box open */
static const struct Key search_keys[] = {
	{ .ev = { .key = TB_KEY_ARROW_LEFT },
					.callback = move_search_left },
	{ .ev = { .key = TB_KEY_ARROW_RIGHT },
					.callback = move_search_right },
	{ .ev = { .key = TB_KEY_BACKSPACE },
					.callback = erase_search_backwards },
	{ .ev = { .key = TB_KEY_BACKSPACE2 },
					.callback = erase_search_backwards },
	{ .ev = { .key = TB_KEY_CTRL_A },
					.callback = move_search_start },
	{ .ev = { .key = TB_KEY_CTRL_E },
					.callback = move_search_end },
	{ .ev = { .key = TB_KEY_CTRL_K },
					.callback = erase_search_to_end },
	{ .ev = { .key = TB_KEY_CTRL_R },
					.callback = move_search_prev_word },
	{ .ev = { .key = TB_KEY_CTRL_S },
					.callback = write_file },
	{ .ev = { .key = TB_KEY_CTRL_T },
					.callback = move_search_next_word },
	{ .ev = { .key = TB_KEY_CTRL_U },
					.callback = erase_search_to_start },
	{ .ev = { .key = TB_KEY_CTRL_W },
					.callback = erase_search_prev_word },
	{ .ev = { .key = TB_KEY_DELETE },
					.callback = erase_search_forward },
	{ .ev = { .key = TB_KEY_END },	.callback = move_search_end },
	{ .ev = { .key = TB_KEY_ENTER },
					.callback = hide_search },
	{ .ev = { .key = TB_KEY_F3 },	.callback = next_match },
	{ .ev = { .key = TB_KEY_F4 },	.callback = prev_match },
	{ .ev = { .key = TB_KEY_HOME },	.callback = move_search_start },
	{ .ev = { .key = TB_KEY_SPACE },
					.callback = insert_search_space },
	{ .ev = { .key = TB_KEY_TAB },	.callback = insert_search_tab },
};

/* Main window */
static const struct Key main_keys[] = {
	{ .ev = { .key = TB_KEY_ARROW_DOWN },
					.callback = move_list_down },
	{ .ev = { .key = TB_KEY_ARROW_UP },
					.callback = move_list_up },
	{ .ev = { .key = TB_KEY_END },
					.callback = move_list_end },
	{ .ev = { .key = TB_KEY_ENTER },
					.callback = show_edit },
	{ .ev = { .key = TB_KEY_F1 },	.callback = show_help },
	{ .ev = { .key = TB_KEY_F3 },	.callback = next_match },
	{ .ev = { .key = TB_KEY_F4 },	.callback = prev_match },
	{ .ev = { .key = TB_KEY_F7 },	.callback = show_search },
	{ .ev = { .key = TB_KEY_F8 },	.callback = next_untranslated },
	{ .ev = { .key = TB_KEY_F9 },	.callback = next_fuzzy },
	{ .ev = { .key = TB_KEY_HOME },	.callback = move_list_start },
	{ .ev = { .key = TB_KEY_CTRL_B },
					.callback = move_list_page_up },
	{ .ev = { .key = TB_KEY_CTRL_F },
					.callback = move_list_page_down },
	{ .ev = { .key = TB_KEY_CTRL_S },
					.callback = write_file },
	{ .ev = { .key = TB_KEY_CTRL_Z },
					.callback = toggle_fuzzy },
	{ .ev = { .key = TB_KEY_PGDN },
					.callback = move_list_page_down },
	{ .ev = { .key = TB_KEY_PGUP },	.callback = move_list_page_up },
	{ .ev = { .ch = '/' },		.callback = show_search },
	{ .ev = { .ch = 'G' },		.callback = move_list_end },
	{ .ev = { .ch = 'H' },		.callback = show_help },
	{ .ev = { .ch = 'f' },		.callback = next_fuzzy },
	{ .ev = { .ch = 'g' },		.callback = move_list_start },
	{ .ev = { .ch = 'j' },		.callback = move_list_down },
	{ .ev = { .ch = 'k' },		.callback = move_list_up },
	{ .ev = { .ch = 'N' },		.callback = prev_match },
	{ .ev = { .ch = 'n' },		.callback = next_match },
	{ .ev = { .ch = 'q' },		.callback = exit_program },
	{ .ev = { .ch = 'u' },		.callback = next_untranslated },
	{ .ev = { .ch = 'w' },		.callback = write_file },
	{ .ev = { .ch = 'z' },		.callback = toggle_fuzzy },
};

#endif /* POE_C_GLOBALS */

void format_filename(char* result, size_t result_size, const char* format,
	const struct DrawState* state);
void format_msgs(char* result, size_t result_size, const char* format,
	const struct DrawState* state);

static const struct StatusSegment status_segments[] = {
	{.format	   = "%s%s",
		.callback  = format_filename,
		.fg	   = TB_BLACK,
		.bg	   = TB_WHITE,
		.alignment = LEFT},
	{.format	   = "%ld/%ld (%ldu/%ldf/%ldo)",
		.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},
};