summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: abd6527)
raw | patch | inline | side by side (parent: abd6527)
author | Matt Portas <matt.r.portas@gmail.com> | |
Thu, 28 Jan 2010 19:38:21 +0000 (20:38 +0100) | ||
committer | Max Kellermann <max@duempel.org> | |
Thu, 28 Jan 2010 19:38:21 +0000 (20:38 +0100) |
Went a control key was pressed it would exit, but still append some
garbage to the end of the search string. This meant that the find
next/previous command didn't work. This patch moves the loop
condition to after getting the key input.
garbage to the end of the search string. This meant that the find
next/previous command didn't work. This patch moves the loop
condition to after getting the key input.
src/screen_find.c | patch | blob | history |
diff --git a/src/screen_find.c b/src/screen_find.c
index e58a1a2ad88ce869d6f12a0b43ef9a028e88580f..0d9d51f0d2ce959f4e5d53dac032ac8811694be7 100644 (file)
--- a/src/screen_find.c
+++ b/src/screen_find.c
search_str = screen.findbuf + g_snprintf(screen.findbuf, WRLN_MAX_LINE_SIZE, "%s: ", JUMP_PROMPT);
iter = search_str;
- /* unfortunately wgetch returns "next/previous-page" not as an ascii-char */
- while(!g_ascii_iscntrl(key) && key != KEY_NPAGE && key != KEY_PPAGE) {
+ while(1) {
key = screen_getch(screen.findbuf);
- /* if backspace or delete was pressed */
- if (key == KEY_BACKSPACE || key == 330) {
+ /* if backspace or delete was pressed, process instead of ending loop */
+ if (key == 127 || key == 330) {
int i;
- /* don't end the loop */
- key = 65;
if (search_str <= g_utf8_find_prev_char(screen.findbuf, iter))
iter = g_utf8_find_prev_char(screen.findbuf, iter);
for (i = 0; *(iter + i) != '\0'; i++)
*(iter + i) = '\0';
continue;
}
+ /* if a control key was pressed, end loop */
+ else if (g_ascii_iscntrl(key) || key == KEY_NPAGE || key == KEY_PPAGE) {
+ break;
+ }
else {
*iter = key;
if (iter < screen.findbuf + WRLN_MAX_LINE_SIZE - 3)