Curses: don't iterate through unbound COLORS #369

On DirectColor-capable terminals with the proper terminfo
database in use, COLORS is 2^24. Since the color map is
only 64k entries, this resulted in a segfault. I've
introduced NC::colorCount(), which bounds it by the
previously assumed maximum (and usable range) of 256.
This commit is contained in:
nick black
2020-01-07 18:41:04 -05:00
parent 31ee76e8ee
commit 302bcca99a
3 changed files with 24 additions and 4 deletions

View File

@@ -219,6 +219,10 @@ void disable();
/// @param enable_colors enables colors
void initScreen(bool enable_colors, bool enable_mouse);
// Get the maximum supported color index (but only once initScreen() has been
// successfully called). This might be less than the advertised COLORS.
int colorCount();
/// Pauses the screen (e.g. for running an external command)
void pauseScreen();