afbjorklund / go-termbg

A Go library for terminal background color detection

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

Verified terminals

If you check other terminals, please report through issue.

Unsupported terminals

"Windows Terminal" may be supported in a future release: microsoft/terminal#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".

ezoic increase your site revenue

About

A Go library for terminal background color detection

License:Apache License 2.0


Languages

Language:Go 100.0%