[NTG-context] coloring the logfile

Taco Hoekwater taco at elvenkind.com
Thu Aug 29 10:58:58 CEST 2019


Hi,

FWIW: ConTeXt can already do colours on the terminal:

   context —ansi myfile.tex

(but that currently results in an empty log, I think because there is no
separation)

Since the engine internals know and expose the difference between terminal 
and log file already, it is quite possible to split the lua messaging code 
into separate 'log' and 'term’ cases, if desired. There is no need to patch 
the engine for that, just some extra lua code that Hans has to be willing to 
write/include.

However, if support for redirect of stdout is needed (because in that case
the ’term’ in internal TeX speak is not really a terminal), then isatty()
needs to be exposed to Lua in one way or another. 

If you want color in the actual log, then someone has to rewrite the log 
reporting lua code to generate RTF or HTML. Should technically be doable 
as well...

BTW, it is not safe to assume that all ttys actually support ansi colours
(remote terminals quite often do not), so a command-line switch would still 
be needed. 

Best wishes,
Taco


> On 29 Aug 2019, at 10:25, Hans van der Meer <havdmeer at ziggo.nl> wrote:
> 
>> On 29/08/19 5:35 PM, Henning Hraban Ramm wrote:
>> This will need engine support but is in principle dead easy.
> 
> So it seems doable if someone is willing to provide the engine support. I sincerely hope it will be done. With many thanks, of course.

> 
> dr. Hans van der Meer
> 
> 
>> On 29 Aug 2019, at 09:39, Henri Menke <henrimenke at gmail.com> wrote:
>> 
>> 
>> 
>> On 29/08/19 5:35 PM, Henning Hraban Ramm wrote:
>>> 
>>>> Am 2019-08-28 um 21:54 schrieb Hans van der Meer <havdmeer at ziggo.nl>:
>>>> 
>>>> Is it possible to force lines  written in the log with \writestatus to have a specific color? The log can be very substantial and it would be nice to have some lines brought to attention by a different color.
>>> 
>>> As a text file, the log can’t have colors.
>>> 
>>> Only the output to your terminal could have ANSI color codes.
>>> I’d welcome this, too, but then we need additional configuration, color breaks easily on some shells, the feature should adhere to the usual shell variables etc. Don’t know it it would be worth the effort.
>> 
>> This will need engine support but is in principle dead easy.
>> 
>> #include <unistd.h>
>> 
>> if (isatty(fileno(stdout))) {
>>    // color
>> } else {
>>    // no color
>> }
>> 
>>> 
>>> Greetlings, Hraban
>>> ---
>>> https://www.fiee.net
>>> http://wiki.contextgarden.net
>>> https://www.dreiviertelhaus.de
>>> GPG Key ID 1C9B22FD
>>> 
>>> ___________________________________________________________________________________
>>> If your question is of interest to others as well, please add an entry to the Wiki!
>>> 
>>> maillist : ntg-context at ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
>>> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
>>> archive  : https://bitbucket.org/phg/context-mirror/commits/
>>> wiki     : http://contextgarden.net
>>> ___________________________________________________________________________________
>>> 
>> 
>> ___________________________________________________________________________________
>> If your question is of interest to others as well, please add an entry to the Wiki!
>> 
>> maillist : ntg-context at ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
>> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
>> archive  : https://bitbucket.org/phg/context-mirror/commits/
>> wiki     : http://contextgarden.net
>> ___________________________________________________________________________________
> 
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
> 
> maillist : ntg-context at ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________

Taco Hoekwater
Elvenkind BV






More information about the ntg-context mailing list