1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

added check for utf_len in inp_get_char

This commit is contained in:
Dmitry Podgorny 2013-01-06 00:56:59 +02:00
parent ad000db663
commit d870ea1ae6

View File

@ -198,20 +198,25 @@ inp_get_char(char *input, int *size)
} else { } else {
char bytes[MB_CUR_MAX+1]; char bytes[MB_CUR_MAX+1];
size_t utf_len = wcrtomb(bytes, ch, NULL); size_t utf_len = wcrtomb(bytes, ch, NULL);
for (i = 0 ; i < utf_len; i++) {
input[(*size)++] = bytes[i];
}
bytes[utf_len] = '\0';
wprintw(inp_win, bytes);
display_size++; // wcrtomb can return (size_t) -1
if (utf_len < MB_CUR_MAX) {
for (i = 0 ; i < utf_len; i++) {
input[(*size)++] = bytes[i];
}
input[*size] = '\0';
// if gone over screen size follow input bytes[utf_len] = '\0';
int rows, cols; wprintw(inp_win, bytes);
getmaxyx(stdscr, rows, cols); display_size++;
if (display_size - pad_start > cols-2) {
pad_start++; // if gone over screen size follow input
prefresh(inp_win, 0, pad_start, rows-1, 0, rows-1, cols-1); int rows, cols;
getmaxyx(stdscr, rows, cols);
if (display_size - pad_start > cols-2) {
pad_start++;
prefresh(inp_win, 0, pad_start, rows-1, 0, rows-1, cols-1);
}
} }
} }