[OT] Printing source code

Discussion in 'C Programming' started by Kristofer Pettijohn, Sep 1, 2004.

  1. 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!
     
    Kristofer Pettijohn, Sep 1, 2004
    #1
    1. Advertisements

  2. Kristofer Pettijohn

    Alan Balmer Guest

    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.
     
    Alan Balmer, Sep 1, 2004
    #2
    1. Advertisements

  3. 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
     
    Derrick Coetzee, Sep 1, 2004
    #3
  4. Kristofer Pettijohn

    Fredrik Tolf Guest

    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
     
    Fredrik Tolf, Sep 2, 2004
    #4
  5. 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.
     
    Kenny McCormack, Sep 2, 2004
    #5
  6. Kristofer Pettijohn

    red floyd Guest

    enscript
     
    red floyd, Sep 2, 2004
    #6
  7. I know gvim ( www.vim.org ) would do that.
     
    Karthik Kumar, Sep 2, 2004
    #7
  8. 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.
     
    Michael Wojcik, Sep 3, 2004
    #8
  9. Kristofer Pettijohn

    CBFalconer Guest

    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.
     
    CBFalconer, Sep 3, 2004
    #9
  10. Kristofer Pettijohn

    Ben Pfaff Guest

    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.
     
    Ben Pfaff, Sep 4, 2004
    #10
  11. Kristofer Pettijohn

    CBFalconer Guest

    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 :)
     
    CBFalconer, Sep 4, 2004
    #11
  12. 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.
     
    Kristofer Pettijohn, Sep 5, 2004
    #12
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.