[OT] Printing source code

  • Thread starter Kristofer Pettijohn
  • Start date
K

Kristofer Pettijohn

A bit off topic, as it's not dealing with standards, but I'm just
wondering if anyone has any good recommendations or good experiences
with particular programs (preferably OS X or BSD/Linux) to pretty-print
C code to a printer, colorizing keywords, constants/literals, and
similar things, for output to a printer (or even HTML to be printed
from there).

Thanks!
 
A

Alan Balmer

A bit off topic, as it's not dealing with standards, but I'm just
wondering if anyone has any good recommendations or good experiences
with particular programs (preferably OS X or BSD/Linux) to pretty-print
C code to a printer, colorizing keywords, constants/literals, and
similar things, for output to a printer (or even HTML to be printed
from there).

Thanks!
The Visual Slickedit editor will do all of the above, on quite a few
platforms. I expect that other program editors will do it as well.
 
D

Derrick Coetzee

Kristofer said:
I'm just wondering if anyone has any good recommendations or good experiences
with particular programs [ . . . ] to pretty-print C code to a printer [ . . . ]

There's a tool called code2html for generating HTML versions of source
code (handy as a CGI script too). Here's a sample C output:

http://www.palfrader.org/code2html/examples.c.html

Here's the main site:

http://www.palfrader.org/code2html/

Here's a command line to go from .c to .html:

code2html -l c blah.c blah.html
 
F

Fredrik Tolf

A bit off topic, as it's not dealing with standards, but I'm just
wondering if anyone has any good recommendations or good experiences
with particular programs (preferably OS X or BSD/Linux) to pretty-print
C code to a printer, colorizing keywords, constants/literals, and
similar things, for output to a printer (or even HTML to be printed
from there).

a2ps has worked well for me on Linux. It doesn't colorize, but it sets
different monochrome attributes on different lexical types, like using
italic or bold fonts and underlining, etc. I wouldn't be surprised if
its pretty-printing is customizable somehow, so it may well be possible
to make it colorize as well.

Fredrik Tolf
 
K

Kenny McCormack

a2ps has worked well for me on Linux. It doesn't colorize, but it sets
different monochrome attributes on different lexical types, like using
italic or bold fonts and underlining, etc. I wouldn't be surprised if
its pretty-printing is customizable somehow, so it may well be possible
to make it colorize as well.

Fredrik Tolf

If you use VIM, there is an option to convert the
colorized/syntax-highlighted on-screen view to HTML. Then you can print
the HTML on a color printer. This works very well for me.
 
R

red floyd

Kristofer said:
A bit off topic, as it's not dealing with standards, but I'm just
wondering if anyone has any good recommendations or good experiences
with particular programs (preferably OS X or BSD/Linux) to pretty-print
C code to a printer, colorizing keywords, constants/literals, and
similar things, for output to a printer (or even HTML to be printed
from there).

Thanks!

enscript
 
K

Karthik Kumar

Kristofer said:
A bit off topic, as it's not dealing with standards, but I'm just
wondering if anyone has any good recommendations or good experiences
with particular programs (preferably OS X or BSD/Linux) to pretty-print
C code to a printer, colorizing keywords, constants/literals, and
similar things, for output to a printer (or even HTML to be printed
from there).

Thanks!

I know gvim ( www.vim.org ) would do that.
 
M

Michael Wojcik

A bit off topic, as it's not dealing with standards, but I'm just
wondering if anyone has any good recommendations or good experiences
with particular programs (preferably OS X or BSD/Linux) to pretty-print
C code to a printer, colorizing keywords, constants/literals, and
similar things, for output to a printer (or even HTML to be printed
from there).

The classic Unix program for this sort of thing, I think, is vgrind,
from BSD 3.0. I suspect some of the other options people have
suggested offer more features, though.
 
C

CBFalconer

Michael said:
The classic Unix program for this sort of thing, I think, is
vgrind, from BSD 3.0. I suspect some of the other options
people have suggested offer more features, though.

You don't usually want any such printouts in color - they are
often both slow and expensive. If you want to do any language
specific marking you are better off using black and white and
changing fonts and/or emphasis (bold, italics, underlining, etc).

TextPad has the capability of customizing display to a language,
in quite a flexible manner. I am not sure whether it can be
taught to do the same to a printout, but it can be configured
separately for printing.
 
B

Ben Pfaff

CBFalconer said:
TextPad has the capability of customizing display to a language,
in quite a flexible manner. I am not sure whether it can be
taught to do the same to a printout, but it can be configured
separately for printing.

For what it's worth, Emacs is (of course) able to print a
document that looks just like the on-screen coloring, using the
function ps-print-buffer-with-faces.
 
C

CBFalconer

Ben said:
For what it's worth, Emacs is (of course) able to print a
document that looks just like the on-screen coloring, using the
function ps-print-buffer-with-faces.

Well, Emacs apparently can do anything except restrain MS and end
war. All you have to do is be willing to learn it and to assign
the disk space for it :)
 
K

Kristofer Pettijohn

CBFalconer said:
Well, Emacs apparently can do anything except restrain MS and end
war. All you have to do is be willing to learn it and to assign
the disk space for it :)

This is true... :)

I haven't even been willing to go from vi to vim yet.. I know
emacs enough to get around and not fork a document into the pits
of "what the hell did I just do?", but haven't given much time
to anything else with it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top