lynx-dev
[Top][All Lists]
Advanced

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

Re: [Lynx-dev] Getting color output to work...


From: Thomas Dickey
Subject: Re: [Lynx-dev] Getting color output to work...
Date: Sun, 1 Jan 2017 13:19:20 -0500
User-agent: Mutt/1.5.21 (2010-09-15)

On Sat, Dec 31, 2016 at 04:51:46PM -0800, L A Walsh wrote:
> Hi, I'm having a problem using lynx to display a local
> html-ized file that hilights syntax w/color.
> 
> 
> Specifically, its the output of Vim's convert file to
> html script which dumps the file's highlighting to
> a buffer which one can then write to disk.
> 
> The manpage indicates that it should work using the
> terminal's color settings if it has a curses entry, but
> I'm not getting it to work.

That's interesting.  However: of the available text-browsers:

        lynx uses curses

        w3m uses termcap

        (e)links(2) is hardcoded, using neither curses nor termcap

While lynx does use curses, its color-style feature uses only the tag-types
for coloring.  It doesn't pay any attention to the font-coloring feature
(which appears to have been rarely used in the 1990s when RP came up with
color-style).  Since knowing the tag type is more interesting than the
occasionally-used font-color, it's been hard to be motivated about that
feature.

w3m doesn't appear to do anything with font-color either.

Some of the (e)links(2) variants handle a subset of font-color.
In a quick check here, that's "elinks".

fwiw, I generated all of the colored-text examples on my main website using
vile (with a different syntax/html program).  In a quick check, marked-up
text is 14% of the content (counting lines with css markers).  About 80%
of _that_ is due to a couple of marked-up copies of the terminfo database:

        http://invisible-island.net/ncurses/terminfo.ti.html
        http://invisible-island.net/xterm/terminfo.html

That leaves less than 3% for the various colored examples in discussion.

So it's useful...

(as usual, if someone supplied patches to implement this in lynx,
I'd help with the process)
 
> I added show_color=always to my ~/.lynxrc, but no difference.
> 
> I wanted it sent to a file so I could display the htmtext
> with 'less', but that and direct-to-screen both do not
> work.
> 
> I'm attaching an html output file from a smallish
> C file, as well as a screen-dump of what it looks like.
> 
> What am I doing wrong?
> 
> My terminal emulator is xterm & linux console compatible.
> 
> Thanks much,
> -linda
> 
> 
> 


> <?xml version="1.0" encoding="utf-8"?>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
> <html xmlns="http://www.w3.org/1999/xhtml";>
> <head>
> <title>~/bin/access.c.xhtml</title>
> <meta name="Generator" content="Vim/7.4" />
> <meta name="plugin-version" content="vim7.4_v1" />
> <meta name="syntax" content="c" />
> <meta name="settings" 
> content="dynamic_folds,use_xhtml,use_css,pre_wrap,expand_tabs,hover_unfold,prevent_copy="
>  />
> <meta name="colorscheme" content="linda" />
> <style type="text/css">
> 
> pre { white-space: pre-wrap; font-family: monospace; color: #b8bcda; 
> background-color: #030009; }
> body { font-family: monospace; color: #b8bcda; background-color: #030009; }
> * { font-size: 1em; }
> .SpecialChar { color: #ffc125; }
> .Number { color: #1e90ff; }
> .Type { color: #00ffff; }
> .Conditional { color: #00ff7f; }
> .Comment { color: #999999; }
> .Constant { color: #a088d0; }
> .Label { color: #ffb90f; }
> .PreProc { color: #87ceeb; }
> .Repeat { color: #90ee90; }
> .FoldColumn { color: #ffffff; background-color: #4d4d4d; padding-bottom: 1px; 
> }
> .FoldColumn { text-decoration: none; white-space: pre; }
> 
> body * { margin: 0; padding: 0; }
> 
> .open-fold   > .Folded { display: none;  }
> .open-fold   > .fulltext { display: inline; }
> .closed-fold > .fulltext { display: none;  }
> .closed-fold > .Folded { display: inline; }
> 
> .open-fold   > .toggle-open   { display: none;   }
> .open-fold   > .toggle-closed { display: inline; }
> .closed-fold > .toggle-open   { display: inline; }
> .closed-fold > .toggle-closed { display: none;   }
> 
> 
> /* opening a fold while hovering won't be supported by IE6 and other
> similar browsers, but it should fail gracefully. */
> .closed-fold:hover > .fulltext { display: inline; }
> .closed-fold:hover > .toggle-filler { display: none; }
> .closed-fold:hover > .Folded { display: none; }
> 
> </style>
> <!--[if lt IE 7]><style type="text/css">
> .open-fold   .Folded      { display: none; }
> .open-fold   .fulltext      { display: inline; }
> .open-fold   .toggle-open   { display: none; }
> .closed-fold .toggle-closed { display: inline; }
> 
> .closed-fold .fulltext      { display: none; }
> .closed-fold .Folded      { display: inline; }
> .closed-fold .toggle-open   { display: inline; }
> .closed-fold .toggle-closed { display: none; }
> </style>
> <![endif]-->
> 
> <script type='text/javascript'>
> //<![CDATA[
> 
> function toggleFold(objID)
> {
>   var fold;
>   fold = document.getElementById(objID);
>   if(fold.className == 'closed-fold')
>   {
>     fold.className = 'open-fold';
>   }
>   else if (fold.className == 'open-fold')
>   {
>     fold.className = 'closed-fold';
>   }
> }
> 
> //]]>
> </script>
> </head>
> <body>
> <pre id='vimCodeElement'>
> 
> 
> <span class="Comment">/*</span><span class="Comment"> call 'access' call on 
> file w/mask</span>
> <span class="Comment"> </span><span class="Comment">*/</span>
> 
> 
> <span class="PreProc">#include </span><span 
> class="Constant">&lt;unistd.h&gt;</span>
> <span class="PreProc">#include </span><span 
> class="Constant">&lt;errno.h&gt;</span>
> <span class="PreProc">#include </span><span 
> class="Constant">&lt;stdio.h&gt;</span>
> <span class="PreProc">#include </span><span 
> class="Constant">&lt;stdlib.h&gt;</span>
> <span class="PreProc">#include </span><span 
> class="Constant">&lt;string.h&gt;</span>
> <span class="PreProc">#include </span><span 
> class="Constant">&lt;ctype.h&gt;</span>
> 
> <span class="Type">static</span>  <span class="Type">const</span> <span 
> class="Type">char</span> * help []= {<span class="Constant">&quot;Real 
> UID/GID access (not Effective) test.&quot;</span>,
>                       <span class="Constant">&quot;             access 
> &lt;filename&gt; [&lt;type&gt;]&quot;</span>,
>                       <span class="Constant">&quot;                    type = 
> &lt;mode&gt;[&lt;mode&gt;...]&quot;</span>,
>                       <span class="Constant">&quot;                    mode = 
> &lt;R|W|X&gt;&quot;</span>,
>                       <span class="Constant">&quot;                 no mode 
> tests existence&quot;</span>,
>                       <span class="Number">0</span>,
>                       };
> ;
> <span class="Type">void</span> msg (<span class="Type">const</span> <span 
> class="Type">char</span> *msg[]) {
>   <span class="Type">const</span> <span class="Type">char</span> **p;
>   <span class="Repeat">for</span> (p=msg; p; ++p) {
>     fprintf(<span class="Constant">stderr</span>, <span 
> class="Constant">&quot;</span><span class="SpecialChar">%s</span><span 
> class="SpecialChar">\n</span><span class="Constant">&quot;</span>, p);
>   }
> }
> 
> <span class="Type">void</span> errmsg(<span class="Type">int</span> status, 
> <span class="Type">const</span> <span class="Type">char</span> * msgtxt[]) {
>   msg(msgtxt);
>   exit(status);
> }
> 
> 
> <span class="Type">int</span> main (<span class="Type">int</span> argc, <span 
> class="Type">char</span> **argv) {
>   <span class="Type">char</span> * file;
>   <span class="Type">int</span> mode;
>   <span class="Type">int</span> status;
>   <span class="Type">int</span> err;
> 
>   <span class="Conditional">if</span> (argc&lt;<span class="Number">2</span> 
> || argc&gt;<span class="Number">3</span>) errmsg(<span 
> class="Number">1</span>, help);
>   file=argv[<span class="Number">1</span>];
>   mode=F_OK;
>   <span class="Conditional">if</span> (argc&gt;<span class="Number">2</span>) 
> {
>     <span class="Type">char</span> *modes=argv[<span class="Number">2</span>];
>     <span class="Type">int</span> len = strlen(modes);
>     printf (<span class="Constant">&quot;len=</span><span 
> class="SpecialChar">%d</span><span class="Constant">, s=</span><span 
> class="SpecialChar">%s</span><span class="SpecialChar">\n</span><span 
> class="Constant">&quot;</span>, len, modes);
>     <span class="Type">int</span> i;
>     <span class="Type">const</span> <span class="Type">char</span> * invms[] 
> = {<span class="Constant">&quot;Invalid mode string&quot;</span>,<span 
> class="Number">0</span>};
>     <span class="Type">const</span> <span class="Type">char</span> * invmis[] 
> = {<span class="Constant">&quot;Invalid mode in mode 
> string&quot;</span>,<span class="Number">0</span>};
>     <span class="Conditional">if</span> (len&gt;<span 
> class="Number">3</span>) {
>       errmsg(<span class="Constant">EINVAL</span>, invms);
>     }
>     <span class="Repeat">while</span> (*modes) {
>       <span class="Conditional">switch</span>(toupper(*modes)) {
>         <span class="Label">case</span>(<span class="Constant">'R'</span>):
>           mode |= R_OK;
>         <span class="Label">case</span>(<span class="Constant">'W'</span>):
>           mode |= W_OK;
>         <span class="Label">case</span>(<span class="Constant">'X'</span>):
>           mode |= X_OK;
>         <span class="Label">default</span>:
>           errmsg(<span class="Constant">EINVAL</span>, invmis);
>       }
>       ++modes;
>     }
>   }
>   status=access(file,mode);
>   err=errno;
>   <span class="Conditional">if</span> (status&lt;<span 
> class="Number">0</span>) {
>     perror(file);
>   }
>   exit (err);
> 
> }
> 
> <span class="Comment">/*</span><span class="Comment"> vim&#0058; ts=2 
> sw=2</span>
> <span class="Comment"> </span><span class="Comment">*/</span>
> </pre>
> </body>
> </html>
> <!-- vim: set foldmethod=manual : -->

> _______________________________________________
> Lynx-dev mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/lynx-dev


-- 
Thomas E. Dickey <address@hidden>
http://invisible-island.net
ftp://invisible-island.net

Attachment: signature.asc
Description: Digital signature


reply via email to

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