Displaying line numbers

VilleSkyttä scop at FreeBSD.org
Thu May 1 13:24:21 PDT 2003


On Thu, 2003-05-01 at 20:08, Khachaturov Vassilii wrote:
> > In addition to the line numbers, there should be a <a 
> > name="lXX">XX</a>
> > for all lines so that one can point to them using #lXX in URLs.  Even
> 
> agreed
> 
> > better if the line referred to in this way would be somehow
> > highlighted...
> 
> I doubt this is possible. The #id resolution takes place at the browser
> level,
> the HTTP query sent to the server doesn't normally include it.

Yep.  I meant (but failed to note) that I was thinking about doing this
in JavaScript, using window.location.hash and dynamically setting the
CSS properties for the requested line from the document's onload
handler.  I think that would work.

It might have an impact on the HTML output, possibly requiring a <span>
element around each row, or at least extending the <a name> to enclose
the whole row in order to be simply able to access one object and set
its properties.

By the way, is there a function/ perl module for getting the number of
lines in a file?  `wc -l` of course works...  I think that would be
needed in order to get the line numbers properly left padded with spaces
like in

        1
    [...]
      100
    [...]

Oh, and I have some doubts whether it'll be possible to have the line
numbers with the new Enscript-formatted output... need to check it out. 
We output it line by line so in case enscript emits one line of HTML per
one line of source, it could be trivial.

-- 
\/ille Skyttä
scop at FreeBSD.org




More information about the freebsd-cvsweb mailing list