Short guide on how to configure "Tools" and "Classes" in TextPad
Micaela Serra Setting up direct links to compiling and executing for C, Java and ARM programming
August 2011 Using TextPad 5.2.0 or higher

TextPad is an excellent editor for the Windows environment. The CSC department has a licence for it and it is thus available in all labs machines. It is well worth downloading it and paying the modest fee to use it on your own machine (plus it is the ethical thing to do as in the future you will like to be paid for your efforts as a software producer!). See the link at:

http://www.textpad.com/download/index.html

Textpad allows the extra features of linking to commonly used programs directly, for example a C compiler. Setting it up to work effectively is fairly easy and can increase productivity for a user. The TextPad available on lab machines has already been configured for most common uses as necessary in the particular courses. This short guide summarizes how to enable the personalization. Full detailed instructions are available in the TextPad "help".

The instructions use as running examples the following activities:

It is assumed that the following tools have been installed:

  1. C compiler with MinGW - see the link at http://www.mingw.org/wiki/Getting_Started
  2. Code Sourcery Tool Chain - see the link for the Lite (free) edition at http://www.codesourcery.com/sgpp/lite/arm/portal/subscription?@template=lite

1. Adding a new Tool

existing tools

When wanting to compile a source file directly from within TextPad, almost using TextPad as an IDE (Integrated Development Environment), a "Tool" must be configured to call on the appropriate command together with its parameters plus input and output files.

The required Tool appears from the "Tools" menu, as in the example menu here where a list of existing commands have already been configured.

existing tools

In order to add a new tool, one must use the "Configure" menu.

SELECT: Configure -> Preferences to obtain the dialogue shown in the figure. The small central subwindow lists all the existing tools already configured (or it shows empty).

existing tools

CLICK ON "Add" and SELECT "Program"

A regular set of dialogue windows from the system will appear, allowing navigation to the correct directory from which to choose the program needed to be implemented in the new tool.

 

existing tools

In this example, the gcc.exe compiler for C from MinGW is selected to be the new tool.

SELECT the desired program and its complete path will be incorporated automatically later.

 

existing tools

The Preference dialogue is updated to include the new tool which is given by default the name of its executable file - in this case Gcc.

It is normally useful to change the default name to something more meaningful (see next).

 

existing tools

To change the default name click on the name itself, slowly two times, with a very small pause between the two clicks. This may not work the first few times.

One knows it has worked when the box containing the default name becomes white and the name appears editable (patience is required).

In this figure the previous default name "Gcc" has been changed to "C with Gcc MinGW " .

 

2. Setting the Properties of a Tool

existing tools

SELECT: Configure -> Preferences to obtain the dialogue window

CLICK ON "+" next to "Tools" to display the whole list of tools so far, where "C with Gcc MinGW" should be one of them.

CLICK ON the "C with Gcc MinGW" label in the tree in the left subwindow, to display its current default properties.

 

existing tools

Having selected "C with Gcc MinGW " from the list, a new dialogue window appears displaying the current default properties of this tool (new or not).

The default properties shown are the minimal default ones and probably should be edited as shown here (see next).

  1. Command: C:\MinGW\bin\gcc.exe
    • the full path of the program selected for this tool is displayed
  2. Parameters: $File
    • the only default parameter states that the input file is the currently opened document on which the tool/program will operate
  3. Initial Folder: $FileDir
    • the only default parameterhere states that the directory is the current opened window

The choices shown in this figure are the most commonly used (more examples are shown later). The regularly available options normally used in a command line can be included in the "Parameters" space. The options local to TextPad only are described more below and further information can be found in the TextPad documentation.

CLICK "Apply" and close the window to finalize the process.

existing tools

Command: C:\MinGW\bin\gcc.exe -the full path of the program selected for this tool is displayed

Parameters: $File - states that the input file is the currently opened document (local in TextPad)

-o $(BaseName).exe - states that the output file will be named with the postfix ".exe" and the actual name taken from the original source file name

-Wall and -ansi are simply desirable compiler options

Initial Folder: $FileDir - the only parameter states that the directory is the current opened window (local in TextPad)

3. Deleting a Tool

existing tools

SELECT: Configure -> Preferences to obtain the dialogue window listing all the existing tools already configured.

HIGHLIGHT: the tool to be deleted.

CLICK the Delete key above the list.

4. The current configurations available in the labs

C > ARM Assembly (.s)

  • Using CodeSourcery
  • From C source code to ARM Assembly source code
  • The complete path in the Command (not shown in its entirety in the window - use the arrow keys to navigate through it) is:
    • C:\Program Files\CodeSourcery\Sourcery G++ Lite\bin\arm-none-eabi-gcc.ex

C > ARM Assembly Optimize:L1 (.s)

  • Using CodeSourcery
  • From C source code to ARM Assembly source code
  • Level 1 optimization
  • The complete path in the Command (not shown in its entirety in the window - use the arrow keys to navigate through it) is:
    • C:\Program Files\CodeSourcery\Sourcery G++ Lite\bin\arm-none-eabi-gcc.exe
  • The complete line in the Parameters (not shown in its entirety in the window - use the arrow keys to navigate through it) is:
    • -S -O1 -Wall -mcpu=arm7tdmi $File -o $(BaseName).s

C > ARM Assembly Optimize:L2 (.s)

  • Using CodeSourcery
  • From C source code to ARM Assembly source code
  • Level 2 optimization
  • The complete path in the Command (not shown in its entirety in the window - use the arrow keys to navigate through it): C:\Program Files\CodeSourcery\Sourcery G++ Lite\bin\arm-none-eabi-gcc.exe
  • The complete line in the Parameters (not shown in its entirety in the window - use the arrow keys to navigate through it): -S -O2 -Wall -mcpu=arm7tdmi $File -o $(BaseName).s

C > ARM Binary (.o)

  • Using CodeSourcery
  • From C source code to ARM binary code
  • The complete path to the Command (not shown in its entirety in the window - use the arrow keys to navigate through it): C:\Program Files\CodeSourcery\Sourcery G++ Lite\bin\arm-none-eabi-gcc.exe

C > ARM program (.elf)

  • Using CodeSourcery
  • From C source code to ARM executable (use the CodeSourcery simulator)
  • The complete path in the Command (not shown in its entirety in the window - use the arrow keys to navigate through it): C:\Program Files\CodeSourcery\Sourcery G++ Lite\bin\arm-none-eabi-gcc.exe

ARM Assembly > Binary (.o)

  • Using CodeSourcery assembler
  • From ARM source code to ARM binary code
  • The complete path to the Command (not shown in its entirety in the window - use the arrow keys to navigate through it): C:\Program Files\CodeSourcery\Sourcery G++ Lite\bin\arm-none-eabi-as.exe

ARM Assembly > ARM program (.elf)

  • Using CodeSourcery compiler
  • From ARM source code to ARM executable (use the CodeSourcery simulator)
  • The complete path in the Command (not shown in its entirety in the window - use the arrow keys to navigate through it): C:\Program Files\CodeSourcery\Sourcery G++ Lite\bin\arm-none-eabi-gcc.exe

C with Gcc MinGW (.exe)

  • Using MinGW C compiler
  • From C source code to executable

5. Executing a program in C

Executing a C program is normally done from the DOS/cmd window independently of TextPad. However it can also be linked in TextPad and the TextPad output window frame is used for the output.

To set this up when adding a new Tool, use the "Add" drop menu as seen earlier, but select "DOS command ..." (instead of "Program..."). In the pop-up window, enter " $BaseName.exe" which later appears in the Parameters line of the tool configuration (see figure). When executing this tool, the Command calls a DOS window ("cmd.exe") within which the executable of a previously compiled C file is run through the call to " $BaseName.exe" as long as the files are resident in the same directory.

6. Java: compiling and executing

The figures below show the commands and parameters needed for compiling and running a Java program. Different version of Java may exist, thus the command path may have variations.

7. Customizing the Files (through Document Classes)

File type

TextPad can detect a file type by its postfix on the file name (for example, source1.c for a C file or source2.s for an ARM Assembly file), so that it can display it using various customization choices, very helpful for reading and debugging. New file types can also be added.


SELECT Configure -> Preferences and open the "Document Classes" tree. Each of the classes listed has a custom configuration attached. The figure shows the initial options set for ARM Assembly language files. By clicking on each sub-category (e.g. Colors) one can change the settings.

 

Adding a new file type using the Document Class

CLICK ON "Document Classes" and type the name of a new class in the empty box at the end of the list for the currently defined user classes.