[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: lynx-dev Any way to pass a literal ESC to the terminal?

From: Klaus Weide
Subject: Re: lynx-dev Any way to pass a literal ESC to the terminal?
Date: Sun, 17 Oct 1999 05:21:24 -0500 (CDT)

On Sat, 16 Oct 1999, David West wrote:
[ reordered for quoting ]

> I would like to be able to view a local text file which contains ANSI
> color escape codes, and have Lynx pass these codes to the terminal, which
> knows how to interpret them.  I thought that this should be possible
> by setting the display charset to Transparent, and/or also setting the
> assumed document charset to x-transparent, but I haven't found a way to
> get it to work.  Any hints would be appreciated.

It was a good guess, but Transparent just isn't *that* transparent.

> The actual appearance of these files, using Lynx, is consistent with
> the ESC chars being removed before reaching the screen, which seems to
> indicate that the ECSs are being eaten by the Lynx code proper, and not 
> by the ncurses with which this version of Lynx was built (ncurses would 
> render an ESC as the two chars ^[, according to the docs I have).

Yes, and that is fully intentional.  It isn't possible to pass a
literal ESC to the terminal through lynx's "built-in viewer".  If
it would be, I would consider it a bug.

Control characters are filtered out early in processing (except the
"meaningful" ones like CR, LF, TAB wich get interpreted in some
way).  The only case where they aren't filtered out immediately is
with the CJK character sets, where lynx interprets some escape
sequences that are used for code switching.

Lynx (via ncurses etc.) creates its own escape sequences to control
the display.  Letting through arbitrary ESC's would interfere with
those and with the lynx screen.  Lynx would have to keep track of
the effect those escape sequences have on the screen, and all
potentially harmful sequences wiuld have to be filtered out.  That's
basically impossibly without lynx itself understanding the full logic
of a terminal (for all possible terminals...). It would have to become
a terminal emulator itself.

> The local text files concerned contain no special headers, and have no
> special filename extension.  As far as I can tell, they should therefore
> be treated by Lynx as text/plain.  When I cat them to the terminal, I
> see the ANSI color as I expect.  These files are the leaf nodes of
> a hypertext tree.  Since I am formatting them myself, I could give
> them extra headers (but what?) if that's what it takes to see the colors.

It seems you don't really need those files displayed by lynx itself
(with its internal viewer).  I assume you want to see them in color,
but it doesn't have to be lynx that shows them - lynx is only needed
to navigate to those leaves in the tree.

If that is the case, then you can just set up an external viewer
for those files.  'less -r' should do (or substitute something
more fancy if you have and need it).

One way would be to
  - give those files a special file suffix.  Let's say ".mytxt".
  - invent a MIME type for them. Let's say "text/x-mytxt".
  - associate suffix with MIME type.  For example put
       text/x-mytxt            mytxt
    in your ~/.mime.types or /etc/mime.types.  You could also use
    SUFFIX in lynx.cfg.
  - define a VIEWER in lynx.cfg, like
       VIEWER:text/x-mytxt:less -r %s

That should be all.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]