mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-29 21:16:21 +00: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:
@@ -328,7 +328,30 @@ _inp_write(char* line, int offset)
|
|||||||
getyx(inp_win, y, x);
|
getyx(inp_win, y, x);
|
||||||
col += 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);
|
wmove(inp_win, 0, col);
|
||||||
_inp_win_handle_scroll();
|
_inp_win_handle_scroll();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user