nmh-workers
[Top] [All Lists]

Re: [Nmh-workers] colorized/highlighted scan output?

2012-11-03 19:27:05

On 2012-11-03, at 4:33 PM, Ralph Corderoy wrote:

But it limits them to colour-setting terminfo entries.  Surely the first
step is to allow an arbitrary binary string through as it permits
everything;  the user can decide how to wangle what they want into the
format file.

But you're still dealing with the issue of tracking the column counter. A 
binary string can contain printable characters, and what's printable will vary 
depending on the charset and current locale. Unless you can embed knowledge of 
all locales and and all charsets into your binary putstring function, sooner or 
later (sooner) it's going to get it wrong.

So stop pretending these are binary blobs and call them for what they are: 
terminal-specific display attributes.  As soon as you do that, the interface 
and implementation become crystal clear.

Here are some other issues I have with the binary blob scheme:

1) What happens when I run scan on a terminal that doesn't support the colour 
escape sequences?  Do I have to specify a different format file when running on 
a non-colour-aware terminal?  What about a terminal emulator that uses 
different escape sequences?  This is poor user-interface design.  Anything that 
messes with the terminal attributes has to be smart enough to do the right 
thing for the specific terminal type being spoken to.  That's why we have 
terminfo.

2) What happens to the terminal state when the program is interrupted in the 
midst of printing to the terminal?  You are potentially leaving the terminal 
using a non-default colour scheme (which can be a pain to recover from), or 
worse, you can leave the terminal completely locked up, recovery from which 
might require blowing away they entire login session (think power cycling a 
terminal on a serial port that uses full hardware handshaking, forcing a logout 
when CD goes away).  A binary blob emitter cannot know the state of the 
terminal, so it can't recover intelligently.  A purpose built formatter knows 
the state of the terminal, and can register an atexit() handler that resets the 
terminal's state if that's necessary.

 Patterns of usage that arise can have dedicated syntax if
deemed popular enough, or is someone adds to the growing code base.  :-)

Oh good grief!  You can't tell me people don't know what the "useful" set of 
terminal display attributes is :-P

--lyndon


_______________________________________________
Nmh-workers mailing list
Nmh-workers(_at_)nongnu(_dot_)org
https://lists.nongnu.org/mailman/listinfo/nmh-workers

<Prev in Thread] Current Thread [Next in Thread>