python-devtools icon indicating copy to clipboard operation
python-devtools copied to clipboard

Improve legibility on light-background terminals

Open dlitz opened this issue 10 months ago • 1 comments

This fixes the problem of light-gray text being rendered on a light background.

Users can now choose a different Pygments style/theme using the PY_DEVTOOLS_STYLE environment variable.

If PY_DEVTOOLS_STYLE is not set, we attempt auto-detection using the COLORFGBG environment variable, as is commonly done by some tools on Linux and macOS.

  • Dark-background terminals use the "vim" style, as before.
  • Light-background terminals now use the "sas" style.
  • If auto-detection fails, we use the "default" style, which is legible on most terminals.

A list of available styles can be obtained by running:

import pygments.styles
list(pygments.styles.get_all_styles())

Screenshots

Light background (COLORFGBG=0;15)

Before After
Screenshot_20240418_192705 Screenshot_20240418_192901

Dark background (COLORFGBG=15;0)

Before After
Screenshot_20240418_192757 Screenshot_20240418_192825

Indeterminate (COLORFGBG missing or unparsable)

Dark Background Light Background
Screenshot_20240418_193510 Screenshot_20240418_193640

dlitz avatar Apr 19 '24 02:04 dlitz

Fixed the commit message & CI builds.

dlitz avatar Apr 19 '24 02:04 dlitz