knurling-rs / probe-run

Run embedded programs just like native ones
Apache License 2.0
644 stars 75 forks source link

Disable output colorization on terminals that don't support it #318

Closed fhars closed 2 years ago

fhars commented 2 years ago

The current version of the colored crate ignores the capabilities of the terminal (see https://github.com/mackwic/colored/issues/108), which makes the outupt of probe-run unparseable in e.g. emacs compilation mode. As a temporary workaround, this patch overrides colorization if probe-run is called from a terminal without color support.

jonas-schievink commented 2 years ago

Does emacs' compilation mode present itself as a terminal (via isatty) to the program (I do hope we support non-isatty mode properly already, so perhaps it doesn't)? Does it set something like TERM=dumb that we could detect instead?

Urhengulas commented 2 years ago

Does emacs' compilation mode present itself as a terminal (via isatty) to the program (I do hope we support non-isatty mode properly already, so perhaps it doesn't)? Does it set something like TERM=dumb that we could detect instead?

From reading https://github.com/mackwic/colored/issues/108 I understood that it is setting TERM=dumb. But I don't know if this is the only trigger we want to look out for, or if there is other ones as well?

Urhengulas commented 2 years ago

@fhars Since it is a temporary fix until colored handles it properly, would it be enough for your purposes to only check TERM=dumb and disable coloring then?

fhars commented 2 years ago

That would fix the immediate use case of running it in a emacs compilation buffer, but the terminfo database on my system knows about 1332 kinds of terminal that do not have color support. (Although most of these are probably collectors items by now, it's decades since I have seen an operational tek4013).

And given that colored seems to be in deep hibernation for the last years, nothing may last as long as a stopgap measure.

Urhengulas commented 2 years ago

Superseded by #320