mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-01-19 17:12:45 +08:00
common.cpp: check wcwidth for supported characters
Rather than trying to detect Unicode support from the environment, check the printable width of characters in the current locale before deciding on whether to use them. Closes #1927.
This commit is contained in:
parent
546ba888ae
commit
e56f0628d5
|
@ -525,13 +525,10 @@ wcstring wsetlocale(int category, const wchar_t *locale)
|
|||
/*
|
||||
Use ellipsis if on known unicode system, otherwise use $
|
||||
*/
|
||||
char *ctype = setlocale(LC_CTYPE, NULL);
|
||||
bool unicode = (strstr(ctype, ".UTF") || strstr(ctype, ".utf"));
|
||||
|
||||
ellipsis_char = unicode ? L'\x2026' : L'$';
|
||||
ellipsis_char = (wcwidth(L'\x2026') > 0) ? L'\x2026' : L'$';
|
||||
|
||||
// U+23CE is the "return" character
|
||||
omitted_newline_char = unicode ? L'\x23CE' : L'~';
|
||||
omitted_newline_char = (wcwidth(L'\x23CE') > 0) ? L'\x23CE' : L'~';
|
||||
|
||||
if (!res)
|
||||
return wcstring();
|
||||
|
|
|
@ -1424,6 +1424,7 @@ void s_reset(screen_t *s, screen_reset_mode_t mode)
|
|||
wcstring abandon_line_string;
|
||||
abandon_line_string.reserve(screen_width + 32); //should be enough
|
||||
|
||||
/* Don't need to check for wcwidth errors; this is done when setting up omitted_newline_char in common.cpp */
|
||||
int non_space_width = wcwidth(omitted_newline_char);
|
||||
if (screen_width >= non_space_width)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user