mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-29 13:23:53 +08:00
Fix for an issue where the newline character would appear on blank lines. Instead of inverting the newline character, draw it in gray.
This commit is contained in:
parent
268d64d244
commit
412902e4ae
2
color.h
2
color.h
|
@ -135,7 +135,7 @@ public:
|
|||
/** Returns whether the color is bold */
|
||||
bool is_bold() const
|
||||
{
|
||||
return flags & flag_bold;
|
||||
return !! (flags & flag_bold);
|
||||
}
|
||||
|
||||
/** Set whether the color is bold */
|
||||
|
|
19
screen.cpp
19
screen.cpp
|
@ -1361,17 +1361,32 @@ void s_reset(screen_t *s, screen_reset_mode_t mode)
|
|||
/* Do the PROMPT_SP hack */
|
||||
int screen_width = common_get_width();
|
||||
wcstring abandon_line_string;
|
||||
abandon_line_string.reserve(screen_width);
|
||||
abandon_line_string.reserve(screen_width + 32); //should be enough
|
||||
|
||||
int non_space_width = wcwidth(omitted_newline_char);
|
||||
if (screen_width >= non_space_width)
|
||||
{
|
||||
abandon_line_string.append(L"\x1b[7m"); //invert text ANSI escape sequence
|
||||
if (output_get_supports_term256())
|
||||
{
|
||||
// draw the string in term256 gray
|
||||
abandon_line_string.append(L"\x1b[38;5;245m");
|
||||
}
|
||||
else
|
||||
{
|
||||
// draw in "bright black" (gray)
|
||||
abandon_line_string.append(L"\x1b[0m" //bright
|
||||
L"\x1b[30;1m"); //black
|
||||
}
|
||||
abandon_line_string.push_back(omitted_newline_char);
|
||||
abandon_line_string.append(L"\x1b[0m"); //normal text ANSI escape sequence
|
||||
abandon_line_string.append(screen_width - non_space_width, L' ');
|
||||
|
||||
}
|
||||
abandon_line_string.push_back(L'\r');
|
||||
// now we are certainly on a new line. But we may have dropped the omitted newline char on it. So append enough spaces to overwrite the omitted newline char, and then
|
||||
abandon_line_string.append(non_space_width, L' ');
|
||||
abandon_line_string.push_back(L'\r');
|
||||
|
||||
const std::string narrow_abandon_line_string = wcs2string(abandon_line_string);
|
||||
write_loop(STDOUT_FILENO, narrow_abandon_line_string.c_str(), narrow_abandon_line_string.size());
|
||||
s->actual.cursor.x = 0;
|
||||
|
|
Loading…
Reference in New Issue
Block a user