go-termbg

module
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 5, 2022 License: Apache-2.0

README

go-termbg

A Go library for terminal background color detection. The detected color is provided by RGB or theme ( dark or light ).

Based on https://github.com/dalance/termbg for Rust

This is a temporary fork due to a problem with v0.3.0 having a bug when you go get it directly.

Verified terminals

If you check other terminals, please report through issue.

Unsupported terminals

"Windows Terminal" may be supported in a future release: https://github.com/microsoft/terminal/issues/3718.

Check program

This module provides a simple program to check.

$ go run ./...
Check terminal background color
  Term : XtermCompatible
  Color: R=2e2e, G=3434, B=3636
  Theme: Dark

Detecting mechanism

If the terminal is win32 console, WIN32API is used for detection. If the terminal is xterm compatible, "Xterm Control Sequences" is used.

The detected RGB is converted to YCbCr. If Y > 0.5, the theme is detected as "light", otherwise "dark".

Directories

Path Synopsis
cmd
termbg command
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL