[PATCH 3 of 4] color: automatically define 16 and 256 colors if supported

Jun Wu quark at fb.com
Mon Jul 10 00:21:13 EDT 2017


Excerpts from Gregory Szorc's message of 2017-07-09 16:46:16 -0700:
> [...]
> @@ -146,6 +179,43 @@ def _terminfocolors(ui):
>      for color, value in TERMINFO_COLOR_8.items():
>          colors[color] = (value, False)
>  
> +    # Add 16 and 256 bit colors if supported and allowed by config policy.
> +    #
> +    # There's no reliable way to detect if the extra colors will actually work.
> +    # The terminfo database just reports what the current terminal is
> +    # advertising. Some terminals support querying the value of a color via
> +    # e.g. \e]4;%d;?\a. However, this isn't universally supported. So set
> +    # colors based purely on terminfo and provide users a way to disable in
> +    # case it doesn't work.
> +
> +    # Will likely return -1 on failure.
> +    termcolors = curses.tigetnum('colors')

Should we check if curses is None here? It seems "debugcolor" will call this
and could be problematic on Windows.


More information about the Mercurial-devel mailing list