Fix color restoring

This commit is contained in:
Maxime Coste 2015-09-12 10:54:55 +01:00
parent ad2aa35546
commit a2b4bf09fd

View File

@ -140,9 +140,6 @@ constexpr struct { unsigned char r, g, b; } builtin_colors[] = {
static void restore_colors() static void restore_colors()
{ {
if (not can_change_color())
return;
for (size_t i = 8; i < COLORS; ++i) for (size_t i = 8; i < COLORS; ++i)
{ {
auto& c = builtin_colors[i]; auto& c = builtin_colors[i];
@ -287,7 +284,9 @@ NCursesUI::~NCursesUI()
{ {
puts("\033[?1004l"); puts("\033[?1004l");
puts("\033[?1002l"); puts("\033[?1002l");
const bool changed_color = can_change_color();
endwin(); endwin();
if (changed_color)
restore_colors(); restore_colors();
signal(SIGWINCH, SIG_DFL); signal(SIGWINCH, SIG_DFL);
signal(SIGINT, SIG_DFL); signal(SIGINT, SIG_DFL);