This is format_comment v1.6 
Copyright Friday Software & Consulting, 1995 All Rights Reserved
Usage and redistribution is subject to the MiscKit license.

Please send bugs and suggestions to:<bbum@friday.com>
Improvements by:
        K. Lo Shih <lo@apdg.com>

format_comment is intended to be used as a service.  For those of you using Edit as your primary code editor, it can be set up as a User Pipe.  For those of you NOT running TickleServices (GET IT-- SEND SCOTT MONEY!!! IT IS WORTH EVERY PENNY!!!), you can set it up as a Terminal Service.  For those of you using TickleServices, install the following service (or something like it):

# Expand any tabs in the text.
set text [expand [pasteboard read]]

set text [nexec /usr/local/etc/format_comment << $text]

# Unexpand leading spaces to tabs and put results on the pasteboard.
pasteboard write $text

[nexec can be found in the !initialization! of a number of the TickleServices files included with the package].  I set up the service on cmd-$... it is convenient and generally available from anywhere.

format_comment reformats anything it finds on stdin into some form of c comment and spews the formatted text out stdout.    The format of the commetn is determined by the first characters encountered.  For example, if you wanted to format a comment with "****"s down the left side and a row of "="s above and below that is indented about half-way, you would start with:

                                  /****= hello world. this is a comment that is way indented and is blocked by ==== signs.  nifty neato.  bet you would stop and look at this if you were reading a piece of code, huh?

and by selecting the text by triple-clicking then piping through format_comment, you would get:

                                  /*** ====================================
                                  **** hello world. this is a comment that
                                  **** is way indented and is blocked by
                                  **** ==== signs.  nifty neato.  bet you
                                  **** would stop and look at this if you
                                  **** were reading a piece of code, huh?
                                  **** ====================================
                                  ***/

format_comment supports the following comment styles.  The stuff in single-quotes were the characters placed at the beginning of the stuff to be commented-- that is, the format_comment seed.

/*"
 * '""' autodoc comments! Some text more text red text blue text up text
 * down text you text me text context.
"*/

        /*
         * 'nothing' default comment style (with a bunch of indent). Some
         * text more text red text blue text up text down text you text me
         * text context.
         * 
         */

               // '//' obj-c style inline comments (useful for commenting
               // blocks in code without wasted vertical space). Some text
               // more text red text blue text up text down text you text
               // me text context.

        /* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
         * you can also use '/*-';.... Some text more text red text blue
         * text up text down text you text me text context.
         * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
         */

                  /***********
                  ************ '/*************'  any size ****** blocks.
                  ************ blocks. blocks. blocks. blocks. blocks.
                  ************ blocks. blocks. blocks. blocks. blocks.
                  ************ blocks.
                  ************ 
                  ***********/

And, best of all, you can easily an existing comment with no worrys about formatting and such-- format_comment will automatically re-format the entire block.

As well, format_comment preserves paragraphs.  For example:-

                                      // This is a comment that has been
                                      // formatted and subsequently edited.  See we added this line of stuff....
                                      // 
                                      // This is the second paragraph
				      
I then selected the above and spewed it through format_comment:

                                      // This is a comment that has been
                                      // formatted and subsequently edited.
                                      // See we added this line of
                                      // stuff....
                                      // 
                                      // This is the second paragraph

Send features, bugs, suggestions to <bbum@friday.com> (the author).

b.bum