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. Adding a new Tool
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. |
|
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). |
|
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.
|
|
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.
|
|
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).
|
|
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
|
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.
|
|
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).
|
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. |
|
|
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
|
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)
|
C > ARM Assembly Optimize:L1 (.s)
|
C > ARM Assembly Optimize:L2 (.s)
|
C > ARM Binary (.o)
|
C > ARM program (.elf)
|
ARM Assembly > Binary (.o)
|
ARM Assembly > ARM program (.elf)
|
C with Gcc MinGW (.exe)
|
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.
|
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. |