1
0
mirror of https://github.com/profanity-im/profanity.git synced 2025-01-03 14:57:42 -05:00

Proper fix for #235

This commit is contained in:
James Booth 2013-09-04 23:14:35 +01:00
parent 0e7ddfea08
commit 03d266d2a8

View File

@ -250,9 +250,6 @@ _clear_input(void)
static int static int
_handle_edit(int result, const wint_t ch, char *input, int *size) _handle_edit(int result, const wint_t ch, char *input, int *size)
{ {
if (result != KEY_CODE_YES) {
return 0;
}
char *prev = NULL; char *prev = NULL;
char *next = NULL; char *next = NULL;
int inp_x = 0; int inp_x = 0;
@ -375,6 +372,9 @@ _handle_edit(int result, const wint_t ch, char *input, int *size)
case 127: case 127:
case KEY_BACKSPACE: case KEY_BACKSPACE:
if (result != KEY_CODE_YES) {
return 0;
}
roster_reset_search_attempts(); roster_reset_search_attempts();
if (display_size > 0) { if (display_size > 0) {
@ -426,6 +426,9 @@ _handle_edit(int result, const wint_t ch, char *input, int *size)
return 1; return 1;
case KEY_DC: // DEL case KEY_DC: // DEL
if (result != KEY_CODE_YES) {
return 0;
}
if (inp_x == display_size-1) { if (inp_x == display_size-1) {
gchar *start = g_utf8_substring(input, 0, inp_x); gchar *start = g_utf8_substring(input, 0, inp_x);
for (*size = 0; *size < strlen(start); (*size)++) { for (*size = 0; *size < strlen(start); (*size)++) {
@ -459,6 +462,9 @@ _handle_edit(int result, const wint_t ch, char *input, int *size)
return 1; return 1;
case KEY_LEFT: case KEY_LEFT:
if (result != KEY_CODE_YES) {
return 0;
}
if (inp_x > 0) { if (inp_x > 0) {
wmove(inp_win, 0, inp_x-1); wmove(inp_win, 0, inp_x-1);
@ -471,6 +477,9 @@ _handle_edit(int result, const wint_t ch, char *input, int *size)
return 1; return 1;
case KEY_RIGHT: case KEY_RIGHT:
if (result != KEY_CODE_YES) {
return 0;
}
if (inp_x < display_size) { if (inp_x < display_size) {
wmove(inp_win, 0, inp_x+1); wmove(inp_win, 0, inp_x+1);
@ -483,6 +492,9 @@ _handle_edit(int result, const wint_t ch, char *input, int *size)
return 1; return 1;
case KEY_UP: case KEY_UP:
if (result != KEY_CODE_YES) {
return 0;
}
prev = cmd_history_previous(input, size); prev = cmd_history_previous(input, size);
if (prev) { if (prev) {
inp_replace_input(input, prev, size); inp_replace_input(input, prev, size);
@ -490,6 +502,9 @@ _handle_edit(int result, const wint_t ch, char *input, int *size)
return 1; return 1;
case KEY_DOWN: case KEY_DOWN:
if (result != KEY_CODE_YES) {
return 0;
}
next = cmd_history_next(input, size); next = cmd_history_next(input, size);
if (next) { if (next) {
inp_replace_input(input, next, size); inp_replace_input(input, next, size);
@ -501,12 +516,18 @@ _handle_edit(int result, const wint_t ch, char *input, int *size)
return 1; return 1;
case KEY_HOME: case KEY_HOME:
if (result != KEY_CODE_YES) {
return 0;
}
wmove(inp_win, 0, 0); wmove(inp_win, 0, 0);
pad_start = 0; pad_start = 0;
_inp_win_refresh(); _inp_win_refresh();
return 1; return 1;
case KEY_END: case KEY_END:
if (result != KEY_CODE_YES) {
return 0;
}
_go_to_end(display_size); _go_to_end(display_size);
return 1; return 1;