pmmp / PocketMine-MP

A server software for Minecraft: Bedrock Edition in PHP
https://pmmp.io
GNU Lesser General Public License v3.0
3.28k stars 1.56k forks source link

Console output looks terrible on BoW terminals #4662

Open SOF3 opened 2 years ago

SOF3 commented 2 years ago

Issue description

PocketMine hardcodes WHITE and GRAY for info and debug. https://github.com/pmmp/PocketMine-MP/blob/59de045ecbacfb9acc297e75170819727d68ae09/src/utils/MainLogger.php#L114-L121

It looks like this on Black-on-White terminals:

image

While terminal themes are responsible for remapping colors to something appropriate in their palette, black and white are generally not mapped because it might deliberately need to be white/black.

But it just doesn't make sense to render normal info messages as WHITE instead of the default (RESET) color. Why do we need to hardcode them?

OS and versions

Plugins

Crashdump, backtrace or other files

dktapps commented 2 years ago

RESET doesn't only remove colours. We would need something like #4364 to implement this without breaking anything.

dktapps commented 2 years ago

To provide more detailed context on my reasons for stalling this:

There is currently no convenient way to go back to the base colour for log messages (or indeed anything else). This has been worked around in many places by using WHITE formatting codes in command outputs when strings contain coloured parts. RESET is not suitable for such cases, because it will unconditionally revert back to whatever the default text colour is (for example, on Git Bash, it's usually an off-white colour).

This could be addressed if we had some way to rebase coloured text, such that RESET was replaced by a sequence of formatting items introduced by the caller. For example, rebase(TextFormat::YELLOW, TextFormat::RED . "Hello " . TextFormat::RESET . "World") would produce a red Hello and a yellow World, rather than a grey World (or whatever the default terminal colour is).