dotnet-websharper / dotnet-ws

The `dotnet ws` tool
Apache License 2.0
1 stars 3 forks source link

Color for info/log messages in the terminal #23

Closed granicz closed 1 year ago

granicz commented 1 year ago

We already use normal/red/yellow for compiler messages in the output that we stream back from the booster. For any other output we generate from dotnet ws, we should pick an appropriate color, for instance, grey or blue. Also, make sure that we use a variant of these colors depending on the background color of the terminal to ensure good visibility.

A simple heuristic would be to calculate the brightness of the background color and choosing a lighter/darker hue in the selected color (darkBlue/cyan, etc.)

// Calculate the brightness of an RGB color
let calculateBrightness (r, g, b) =
    (r * 299 + g * 587 + b * 114) / 1000.0