Nice printing of C++ code using Kwrite/KDevelop? - KDE

This is a discussion on Nice printing of C++ code using Kwrite/KDevelop? - KDE ; Hey there Handing in a programming project tomorrow, and need to print out my C++ code from KDevelop. Kwrite shows the code very, very nicely in KDevelop, with automatic indentation on line breaks, but it's not so pretty when you ...

+ Reply to Thread
Results 1 to 7 of 7

Thread: Nice printing of C++ code using Kwrite/KDevelop?

  1. Nice printing of C++ code using Kwrite/KDevelop?

    Hey there

    Handing in a programming project tomorrow, and need to print out my C++ code
    from KDevelop. Kwrite shows the code very, very nicely in KDevelop, with
    automatic indentation on line breaks, but it's not so pretty when you print
    it. The indentation, e.g., is gone...

    Is there a trick to doing this nicely with Kwrite? Alternatively, a tool to
    convert the cpp and h files to something that pretty that can be printed,
    or even better, imported into openoffice writer?

    Thanks in advance,
    Daniel

    --
    Why do cats jump out of windows? Because there's love out there!

  2. Re: Nice printing of C++ code using Kwrite/KDevelop?

    DanielESFA wrote:

    > Hey there
    >
    > Handing in a programming project tomorrow, and need to print out my C++
    > code from KDevelop. Kwrite shows the code very, very nicely in KDevelop,
    > with automatic indentation on line breaks, but it's not so pretty when you
    > print it. The indentation, e.g., is gone...
    >
    > Is there a trick to doing this nicely with Kwrite? Alternatively, a tool
    > to convert the cpp and h files to something that pretty that can be
    > printed, or even better, imported into openoffice writer?
    >
    > Thanks in advance,
    > Daniel
    >


    Yes convert TAB to spaces. See man expand

    Benny

  3. Re: Nice printing of C++ code using Kwrite/KDevelop?

    DanielESFA wrote:
    > Hey there
    >
    > Handing in a programming project tomorrow, and need to print out my C++ code
    > from KDevelop. Kwrite shows the code very, very nicely in KDevelop, with
    > automatic indentation on line breaks, but it's not so pretty when you print
    > it. The indentation, e.g., is gone...
    >
    > Is there a trick to doing this nicely with Kwrite? Alternatively, a tool to
    > convert the cpp and h files to something that pretty that can be printed,
    > or even better, imported into openoffice writer?
    >
    > Thanks in advance,
    > Daniel
    >


    One of the standard abilities of KDE text apps is to print-to-PDF via
    the File->Print option. I don't have KDevelop installed, but I just
    opened one of my C files in kwrite, printed it to PDF, opened it in
    Acroread and it has all the purty formatting. If it's in the PDF
    document then it should make it to a printer that supports such
    things.

    This would have been nice in KDE 1.x when I was in school! (I just
    used mpage which works well too).

    HTH - JB

    PS: this is KDE 3.3.2

    --------------------------------------------
    John Bleichert - syborg@earthlink.net
    "Every policeman comes equipped with extended claws"

  4. Re: Nice printing of C++ code using Kwrite/KDevelop?

    John Bleichert wrote:

    > DanielESFA wrote:
    >> Hey there
    >>
    >> Handing in a programming project tomorrow, and need to print out my C++
    >> code from KDevelop. Kwrite shows the code very, very nicely in KDevelop,
    >> with automatic indentation on line breaks, but it's not so pretty when
    >> you print it. The indentation, e.g., is gone...
    >>
    >> Is there a trick to doing this nicely with Kwrite? Alternatively, a tool
    >> to convert the cpp and h files to something that pretty that can be
    >> printed, or even better, imported into openoffice writer?
    >>
    >> Thanks in advance,
    >> Daniel
    >>

    >
    > One of the standard abilities of KDE text apps is to print-to-PDF via
    > the File->Print option. I don't have KDevelop installed, but I just
    > opened one of my C files in kwrite, printed it to PDF, opened it in
    > Acroread and it has all the purty formatting. If it's in the PDF
    > document then it should make it to a printer that supports such
    > things.
    >
    > This would have been nice in KDE 1.x when I was in school! (I just
    > used mpage which works well too).
    >
    > HTH - JB
    >
    > PS: this is KDE 3.3.2
    >


    Here, too Thanks for the info, I already tried printing to PDF, though,
    but the probbie is simply that the soft-wrapped, and indented, long lines
    come out wrapping to the left page border rather than being indented, like
    they are on screen. I'd just luv it if it would convert the softwrapping to
    hardwrapped, including the auto-indent...

    --
    Why do cats jump out of windows? Because there's love out there!

  5. Re: Nice printing of C++ code using Kwrite/KDevelop?

    Benny Nielsen wrote:

    > DanielESFA wrote:
    >
    >> Hey there
    >>
    >> Handing in a programming project tomorrow, and need to print out my C++
    >> code from KDevelop. Kwrite shows the code very, very nicely in KDevelop,
    >> with automatic indentation on line breaks, but it's not so pretty when
    >> you print it. The indentation, e.g., is gone...
    >>
    >> Is there a trick to doing this nicely with Kwrite? Alternatively, a tool
    >> to convert the cpp and h files to something that pretty that can be
    >> printed, or even better, imported into openoffice writer?
    >>
    >> Thanks in advance,
    >> Daniel
    >>

    >
    > Yes convert TAB to spaces. See man expand
    >
    > Benny


    Hi, Benny, problem is not converting TAB to spaces, it's the one I described
    above, that the automatic indents on line breaks are lost when printing.
    There's nothing to convert as the indents are purely visual, not tabs...

    --
    Why do cats jump out of windows? Because there's love out there!

  6. Re: Nice printing of C++ code using Kwrite/KDevelop?

    DanielESFA wrote:
    > Handing in a programming project tomorrow, and need to print out my C++ code
    > from KDevelop. Kwrite shows the code very, very nicely in KDevelop, with
    > automatic indentation on line breaks, but it's not so pretty when you print
    > it. The indentation, e.g., is gone...
    >
    > Is there a trick to doing this nicely with Kwrite? Alternatively, a tool to
    > convert the cpp and h files to something that pretty that can be printed,
    > or even better, imported into openoffice writer?


    Have you tried piping your source through the program "indent"? It's designed
    for C, but might do a decent enough job on C++, depending on the input,
    really. I'm sure there must be a C++ equivalent out there. Generally what
    you're looking for is known as a "pretty printer" or "code beautifier", if
    that helps with a search.

    Cheers,

    Matt

    --
    "It's the small gaps between the rain that count,
    and learning how to live amongst them."
    -- Jeff Noon

  7. Re: Nice printing of C++ code using Kwrite/KDevelop?

    Matt Gibson wrote:

    > DanielESFA wrote:
    >> Handing in a programming project tomorrow, and need to print out my C++
    >> code from KDevelop. Kwrite shows the code very, very nicely in KDevelop,
    >> with automatic indentation on line breaks, but it's not so pretty when
    >> you print it. The indentation, e.g., is gone...
    >>
    >> Is there a trick to doing this nicely with Kwrite? Alternatively, a tool
    >> to convert the cpp and h files to something that pretty that can be
    >> printed, or even better, imported into openoffice writer?

    >
    > Have you tried piping your source through the program "indent"? It's
    > designed for C, but might do a decent enough job on C++, depending on the
    > input,
    > really. I'm sure there must be a C++ equivalent out there. Generally
    > what you're looking for is known as a "pretty printer" or "code
    > beautifier", if that helps with a search.
    >
    > Cheers,
    >
    > Matt
    >


    Hey Actually, I just wrote a little program to do it for me, got tired of
    checking out programs

    Cheers,
    Daniel

    --
    Why do cats jump out of windows? Because there's love out there!

+ Reply to Thread