mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Show return symbol for embedded newlines
When editing multi-line messages or comments everything past the first newline becomes invisible. This patch fixes it by substituting a Unicode symbol for "return" instead of printing the newline as is. On locales where it's not available single backslash is used instead.
This commit is contained in:
parent
ccede06a65
commit
8e728fee15
@ -328,7 +328,30 @@ _inp_write(char* line, int offset)
|
||||
getyx(inp_win, y, x);
|
||||
col += x;
|
||||
|
||||
waddstr(inp_win, line);
|
||||
for (size_t i = 0; line[i] != '\0'; i++) {
|
||||
char* c = &line[i];
|
||||
char retc[MB_CUR_MAX];
|
||||
|
||||
size_t ch_len = mbrlen(c, MB_CUR_MAX, NULL);
|
||||
if ((ch_len == (size_t)-2) || (ch_len == (size_t)-1)) {
|
||||
waddch(inp_win, ' ');
|
||||
continue;
|
||||
}
|
||||
|
||||
if (line[i] == '\n') {
|
||||
c = retc;
|
||||
ch_len = wctomb(retc, L'\u23ce'); /* return symbol */
|
||||
if (ch_len == -1) { /* not representable */
|
||||
retc[0] = '\\';
|
||||
ch_len = 1;
|
||||
}
|
||||
} else {
|
||||
i += ch_len - 1;
|
||||
}
|
||||
|
||||
waddnstr(inp_win, c, ch_len);
|
||||
}
|
||||
|
||||
wmove(inp_win, 0, col);
|
||||
_inp_win_handle_scroll();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user