mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Handle deleting wide chars in middle of input
This commit is contained in:
parent
a96e36a55d
commit
772f5857f0
@ -348,13 +348,22 @@ _handle_edit(const wint_t ch, char *input, int *size)
|
|||||||
|
|
||||||
// if in middle, delete and shift chars left
|
// if in middle, delete and shift chars left
|
||||||
} else if (inp_x > 0 && inp_x < display_size) {
|
} else if (inp_x > 0 && inp_x < display_size) {
|
||||||
for (i = inp_x; i < *size; i++)
|
gchar *start = g_utf8_substring(input, 0, inp_x - 1);
|
||||||
input[i-1] = input[i];
|
gchar *end = g_utf8_substring(input, inp_x, *size);
|
||||||
(*size)--;
|
GString *new = g_string_new(start);
|
||||||
|
g_string_append(new, end);
|
||||||
|
|
||||||
|
for (*size = 0; *size < strlen(new->str); (*size)++) {
|
||||||
|
input[*size] = new->str[*size];
|
||||||
|
}
|
||||||
|
input[*size] = '\0';
|
||||||
|
|
||||||
|
g_free(start);
|
||||||
|
g_free(end);
|
||||||
|
g_string_free(new, FALSE);
|
||||||
|
|
||||||
inp_clear();
|
inp_clear();
|
||||||
for (i = 0; i < *size; i++)
|
wprintw(inp_win, input);
|
||||||
waddch(inp_win, input[i]);
|
|
||||||
wmove(inp_win, 0, inp_x -1);
|
wmove(inp_win, 0, inp_x -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user