SourceForge.net Logo






Source Code Formatter (already implemented)


Latest version: 1.02, released June 19, 2007
Includes one bug  fix (see item 10 below), and it might compile properly
with PBWin8 now.


It has many options for formatting details. To save users some time, it's
intended (in the future) to analyse a person's code to determine his
preferences.


Introduction
 It adjusts:
Indentation, spacing, and blank lines according to 17 personalized
settings (indentation rules are preset), which can be saved.


 It works with hot-keys or buttons, to format code selected in
an editor, or code copied to the clipboard.
 If you use hot-keys, it will do the copying and pasting for you. It
also preserves the clipboard's previous contents, so you needn't worry
about losing any data you might have stored there (this only applies to
data in text format, and does not work when using the buttons).



How to Use it (simple directions):

    1) Adjust settings to suit your preferences.

    2) Select at least one sub or function of your code in
       any editor (it works with: PBEdit, WordPad and NotePad
       anyway). In PBEdit, try "Select Block" in the context
       menu to select a single sub or function (after placing
       the caret on the first line of a procedure).

    3) Either:
        a) press Ctrl+1 (the digit "1") and wait for
           the selection to be replaced.
            ...or...
        b) copy the code and press "Format" in the dialog,
           then paste it back when the label says "Ready"

    4) If you don't like the results, then either:
        a) Keep the code selected and press Ctrl+2 (the hot-key).
        ...or...
        b) Press "Revert" on the dialog.

 There's normally no reason to use the buttons for anything. They're only
there just in case.


Using the Hot-keys for Formatting Code:

 The default hot-keys are:
    Ctrl+1 for "Format"
    Ctrl+2 for "Revert"
     These hot-keys will show in the window's caption. They are hard-coded in
    this version. You can change them by editing "Init". Don't use "Q" or "W",
    if you plan to use it with Netscape :)
     Later versions will be more flexible.

 Formatting Selected Code Using the Hot-Key (Ctrl+1)
     The "Format" hot-key, will copy selected text (code) from the window
    on your system which currently has the keyboard focus. It will format it,
    then paste it back over the original code. You don't need to copy or paste
    any code, it will do it for you. You can tell when it's done because the
    code will become completely deselected (and formatted of course).

 Reverting to Original Code Using the Hot-Key (Ctrl+2)
     When you revert to your original code using the hot-key, the program
    will paste the last code it processed back into your editor. You can
    keep the unwanted code selected to avoid deleting it afterward. You can
    of course, use your editor's undo feature, but some editors will discard
    the undo buffer when a file is saved. This "revert" feature provides an
    additional safeguard.

Using the Buttons for formatting:

 Formatting the Clipboard Contents Using the "Format" button
     The "Format" button will process code that you put on the clipboard, then
    replace it with the same code after formatting it. You therefore have to do
    the copying and pasting manually.

 Reverting to Original Code Using the "Revert" button
     The "Revert" button will put the original code that you formatted back on
    the clipboard. You have to do the pasting manually.

   All methods use the colored label to show whether it's "busy" (red) or
    "ready" (green).
     You can toggle the window between "expanded" and "minimized" states with
    the long narrow button below the "Format" and "Revert" buttons.

    To find your way around, select "Show tooltips" in the "Program" frame.

     When you click "Save settings", it will save the states of all the check-
    boxes, plus the window position. All settings are stored in "SrcFrmt.ini",
    in a non-standard format. The "Start minimized" option only collapses the
    dialog, rather than a "normal" minimize.

     "Load settings" applies all of the saved settings including the window's
    position, but not the window's expanded state.



Format of "SrcFrmt.ini"
(you don't need to know this)

     It was designed to make it possible to create a settings file by pasting
    control ID equates into a text file and assigning values to them. These
    values can be checkbox states, textbox contents or anything else.
    The equate names are included for clarity, since they are often descriptive
    of a control's purpose. The only part of the equate names required to be
    present are the type-specifier characters ("%" or "$"), because they tell
    the settings manager whether the data is numeric or string type. The equals
    sign must also be present to tell the settings manager where the ID is.

    You can add comments using the apostrophe, but NOT "REM".

     ID values below 1000, are codes for non-standard settings or operations.
    These can be for window positions, for example, as code number 1 is used in
    this program.

For example:

        Equate Name      =   Control_ID          Setting Value
        %WordWrapChk  =         1001     (TAB)          1


     The ID value is 1001, followed by a TAB character, which is followed by
    its setting value of one. Any number of TABs or spaces can be used before
    the ID value. This is allowed so you can paste your equates directly from
    any editor. TABs are used as delimiters after the ID.


Bugs and Issues:

1)  Fixed:
    Separates the "&H" in hex values
2)  Fixed:
    Lines beginning with "Function" reset tab depth to 0
3)  Fixed:
    Anything following a closing parenthesis was run together.
    An actual example: "temp0 = GetKeyState(%VK_SHIFT)And &H8000"
4)  Fixed:
    Doesn't handle Unions
5)  Fixed:
    In procedures not starting with Locals, it may indent one level
    too deep.
6)  Fixed:
    Compound statements were all treated as "normal code", caused
    indentation errors in lines of other types
7)  Fixed:
    Doesn't always indent continuations of continued lines
8) Fixed:
   Leaves several blank lines at the end of the code
9) Fixed:
   Leaves spaces inside the empty parentheses of Global array
   declarations.
10) Fixed:
   Separated the ampersands ("&") in the type specifiers for Quad variables
   ("&&").
11) Doesn't properly indent lines after a continuation of an "If/Then"
    statement which starts a block-IF.
12) Should also space variable declarations which use type-specifier
    characters (this bug does not affect code integrity).






The source code is in the "srcfrmt" folder of the CVS directory
Browse CVS
Website Home
Project Summary Page at SourceForge.net






This project is sponsored by TheirCorp
(formerly TheirWare Corporation)

TheirCorp Home Page