чување 2f67b8882c4b4d9e4cc16022ac6ca008c97fd186
родитељ b87114bd6e5f1874da1d7209e582b7022f4e81d4
Аутор: Страхиња Радић <contact@strahinja.org>
Датум: Wed, 14 Jul 2021 10:57:06 +0200
Changed fuzzy toggle to 'z'; added goto_msgid as a separate function; reformatted and rephrased Q&A in README
Signed-off-by: Страхиња Радић <contact@strahinja.org>
Diffstat:
| M | README | | | 18 | ++++++++++-------- |
| M | draw.c | | | 4 | ++-- |
| M | poe.1.in | | | 6 | +++--- |
| M | poe.c | | | 78 | ++++++++++++++++++++++++------------------------------------------------------ |
измењених датотека: 4, додавања: 39(+), брисања: 67(-)
diff --git a/README b/README
@@ -11,18 +11,20 @@ A: Because <Go/Rust/whatever soydev language of the moment> sucks.
Q: Why is poe saying there are <N+1> messages in my file when
other editors say there are <N> messages?
-A: Because poe counts (and allows editing of) the first, special msgid.
+A: Because poe takes into account (and allows editing of) the first,
+ special msgid.
Q: This doesn't do X!
-A: See TODO for a list of implemented and planned features. I might consider
- adding a feature if I have time, but already poe has all the major features I
- planned. It is meant to be a simple .po editing program.
+A: See TODO for a list of implemented and planned features. I might
+ consider adding a feature if I have time, but already poe has all
+ the major ones I planned. It is meant to be a simple .po editing
+ program.
Q: Is this suckless?
-A: Definitely not. Any TUI is not suckless. gettext is not suckless, and thus
- .po files are also not suckless. Despite that, some suggestions for a
- suckless approach to editing .po files: vi, ed. termbox is less bloated than
- ncurses, though.
+A: Definitely not. Any TUI is not suckless. gettext is not suckless,
+ and thus .po files are also not suckless. Despite that, some
+ suggestions for a suckless approach to editing .po files are:
+ vi, ed. Still, termbox, used by poe, is less bloated than ncurses.
License
diff --git a/draw.c b/draw.c
@@ -21,7 +21,7 @@ static const char* help[] = {
"n or F3 - Find next",
"N or F4 - Find previous",
"u or F8 - Go to next untranslated entry",
- "F or F9 - Go to next fuzzy entry",
+ "f or F9 - Go to next fuzzy entry",
"w or C-S - Save file (with backup)",
"g or Home - Go to first entry",
"C-B or PgUp - Go to previous page",
@@ -29,7 +29,7 @@ static const char* help[] = {
"j or \u2193 - Go to next entry",
"C-F or PgDn - Go to next page",
"G or End - Go to last entry",
- "f or C-Z - Toggle fuzzy flag",
+ "z or C-Z - Toggle fuzzy flag",
"q or C-Q - Quit",
"See the manual (man poe) for full help."
};
diff --git a/poe.1.in b/poe.1.in
@@ -73,7 +73,7 @@ _
\fCn\fP or \fCF3\fP@Find next
\fCN\fP or \fCF4\fP@Find previous
\fCu\fP or \fCF8\fP@Go to next untranslated entry
-\fCF\fP or \fCF9\fP@Go to next fuzzy entry
+\fCf\fP or \fCF9\fP@Go to next fuzzy entry
\fCw\fP or \fCC-S\fP@Save file (with backup)
\fCg\fP or \fCHome\fP@Go to first entry
\fCC-B\fP or \fCPgUp\fP@Go to previous page
@@ -81,7 +81,7 @@ _
\fCj\fP or \fC\[da]\fP@Go to next entry
\fCC-F\fP or \fCPgDn\fP@Go to next page
\fCG\fP or \fCEnd\fP@Go to last entry
-\fCf\fP or \fCC-Z\fP@Toggle fuzzy flag
+\fCz\fP or \fCC-Z\fP@Toggle fuzzy flag
\fCq\fP or \fCC-Q\fP@Quit
.TE
.
@@ -170,7 +170,7 @@ _
.SH "KNOWN LIMITATIONS"
.
.IP \(bu 4
-This project is currently (July 2021) still a work in progress.
+UTF-8 character set is assumed.
.
.IP \(bu
CJK characters are unsupported/problematic. This is a limitation of termbox
diff --git a/poe.c b/poe.c
@@ -51,6 +51,7 @@ void erase_search_prev_word(struct DrawState* state);
struct DrawState* copy_msgid_to_input(struct DrawState* state);
struct DrawState* yank_msgstr_to_paste_buffer(struct DrawState* state);
struct DrawState* paste_paste_buffer_to_input(struct DrawState* state);
+void goto_msgid(struct DrawState* state, const size_t msgid_number);
void next_match(struct DrawState* state);
void prev_match(struct DrawState* state);
void next_untranslated(struct DrawState* state);
@@ -959,6 +960,23 @@ paste_paste_buffer_to_input(struct DrawState* state)
}
void
+goto_msgid(struct DrawState* state, const size_t msgid_number)
+{
+ state->msgid_number = msgid_number;
+ if (state->msgid_number < (state->maxy-1)/2)
+ state->first_shown_msgid =
+ state->msgid_count > 0 ? 1 : 0;
+ else if (state->msgid_count - state->msgid_number <
+ (state->maxy-1)/2)
+ state->first_shown_msgid = MAX(1,
+ state->msgid_count - (state->maxy-2));
+ else
+ state->first_shown_msgid = MAX(1,
+ state->msgid_number
+ - (state->maxy-1)/2);
+}
+
+void
next_match(struct DrawState* state)
{
if (state->msgid_count == 0 || !state->search || !*state->search)
@@ -976,20 +994,7 @@ next_match(struct DrawState* state)
**current->msgstr && u32_strstr(*current->msgstr,
state->search)))
{
- /* TODO: Have this as a separate function */
- state->msgid_number = e + 1;
- if (state->msgid_number < (state->maxy-1)/2)
- state->first_shown_msgid =
- state->msgid_count > 0 ? 1 : 0;
- else if (state->msgid_count - state->msgid_number <
- (state->maxy-1)/2)
- state->first_shown_msgid = MAX(1,
- state->msgid_count - (state->maxy-2));
- else
- state->first_shown_msgid = MAX(1,
- state->msgid_number
- - (state->maxy-1)/2);
-
+ goto_msgid(state, e+1);
return;
}
}
@@ -1013,20 +1018,7 @@ prev_match(struct DrawState* state)
**current->msgstr && u32_strstr(*current->msgstr,
state->search)))
{
- /* TODO: Have this as a separate function */
- state->msgid_number = e;
- if (state->msgid_number < (state->maxy-1)/2)
- state->first_shown_msgid =
- state->msgid_count > 0 ? 1 : 0;
- else if (state->msgid_count - state->msgid_number <
- (state->maxy-1)/2)
- state->first_shown_msgid = MAX(1,
- state->msgid_count - (state->maxy-2));
- else
- state->first_shown_msgid = MAX(1,
- state->msgid_number
- - (state->maxy-1)/2);
-
+ goto_msgid(state, e);
return;
}
}
@@ -1056,18 +1048,7 @@ next_untranslated(struct DrawState* state)
state->dirty = state->dirty_before_edit;
}
- state->msgid_number = e + 1;
- if (state->msgid_number < (state->maxy-1)/2)
- state->first_shown_msgid =
- state->msgid_count > 0 ? 1 : 0;
- else if (state->msgid_count - state->msgid_number <
- (state->maxy-1)/2)
- state->first_shown_msgid = MAX(1,
- state->msgid_count - (state->maxy-2));
- else
- state->first_shown_msgid = MAX(1,
- state->msgid_number
- - (state->maxy-1)/2);
+ goto_msgid(state, e+1);
if (save_show_edit)
{
@@ -1103,18 +1084,7 @@ next_fuzzy(struct DrawState* state)
state->dirty = state->dirty_before_edit;
}
- state->msgid_number = e + 1;
- if (state->msgid_number < (state->maxy-1)/2)
- state->first_shown_msgid =
- state->msgid_count > 0 ? 1 : 0;
- else if (state->msgid_count - state->msgid_number <
- (state->maxy-1)/2)
- state->first_shown_msgid = MAX(1,
- state->msgid_count - (state->maxy-2));
- else
- state->first_shown_msgid = MAX(1,
- state->msgid_number
- - (state->maxy-1)/2);
+ goto_msgid(state, e+1);
if (save_show_edit)
{
@@ -1962,7 +1932,7 @@ handle_key_event(struct tb_event* ev, struct DrawState* state)
}
state->dirty = 0;
}
- else if (ev->key == TB_KEY_CTRL_Z || ev->ch == 'f')
+ else if (ev->key == TB_KEY_CTRL_Z || ev->ch == 'z')
toggle_fuzzy(state);
else if (ev->key == TB_KEY_END || ev->ch == 'G')
move_list_end(state);
@@ -1989,7 +1959,7 @@ handle_key_event(struct tb_event* ev, struct DrawState* state)
show_search(state);
else if (ev->key == TB_KEY_F8 || ev->ch == 'u')
next_untranslated(state);
- else if (ev->key == TB_KEY_F9 || ev->ch == 'F')
+ else if (ev->key == TB_KEY_F9 || ev->ch == 'f')
next_fuzzy(state);
else if (ev->key == TB_KEY_HOME || ev->ch == 'g')
move_list_start(state);