Skip to content
This repository has been archived by the owner on Jan 5, 2022. It is now read-only.
/ go-termbg Public archive

A Go library for terminal background color detection

License

Notifications You must be signed in to change notification settings

afbjorklund/go-termbg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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".

About

A Go library for terminal background color detection

Resources

License

Stars

Watchers

Forks

Languages