Code Crusader Help

Please submit all suggestions and bugs via github.


Table of Contents


Overview

Code Crusader provides a powerful UNIX development environment. Its major features are:


Project Window

The Project window is a convenient place to store all the files associated with a project and provides a foundation for the interface to GNU make. The tutorial provides an introduction to this interface.

Any file can be added to the project, not only a source file. To do this, use "Add files..." on the Source menu. You can also add a file that is open in a Text Editor window to a project by using the "Add to project" menu on the Tasks menu in the Text Editor window. If you select a file in the project before using "Add files..." or "Add to project", the new files will be inserted after the selection. If you select a group, the new files will be appended to the group.

When you select the files, you can also choose the type of path information to store. The default is relative to the project file's path, which makes it easy to transfer the project's directory structure to a different location or even a different machine. Once a file has been added to the project, its path can be changed by holding down the Meta key and double clicking on the file with the left mouse button. You can then either change the name directly or click on the button to use the Choose File dialog.

To open a file from the Project window, double click with the left button. To open the complement file of a C/C++ source or header file, double click with the middle button. If you have selected multiple files, you can either use the items on the Source menu or the shortcuts Return or Ctrl-Tab. These are the same bindings as in the inheritance trees.

If you add a library to the project and then try to open it, you will be asked to find the project file corresponding to the library. This makes it easy to open sub-projects from the main project window. These sub-projects are automatically built before building the main project. You can change the project file for the library and other options via the "Edit sub-project configuration" item on the Source menu. Each sub-project will be built using the command specified in its own Project Configuration dialog.

As with all lists in Code Crusader, to find a group or a file that is visible, simply type the first few letters of its name.

Groups are used to collect related files and hide them when you are not working on them. To rearrange files or groups, simply select them and drag them to where you want them to be. You can also drag them to other windows that support the XDND protocol, like the multi-file search list in the Search Text dialog. If you drag a group, it is like dragging all the files in that group.

To change the name of a group, simply double click on it.

To open or close a group, click on the triangle to the left of the name. You can also use the following key shortcuts:

Left arrow
Close selected groups
Right arrow
Open selected groups
Shift-left arrow
Close all groups
Shift-right arrow
Open all groups

The Shift modifier also works when clicking on the triangle.

The interface to GNU make

Code Crusader allows you to maintain and use your own Makefile if you wish to do so. However, it is usually preferable to let Code Crusader build the Makefile for you. You have the choice of using either makemake, CMake, or qmake. The basic steps are the same for either one:

  1. Add the source files to the Project window.
  2. Configure the project.
  3. Configure the compiler and linker by editing Make.header (for makemake), CMake.header (for CMake), or QMake.header (for qmake). (Simply click on the Config button in the Project window.)
  4. Ask Code Crusader to build the project by selecting the "Build (via make)" item on the Tasks menu. This first writes Make.files (for makemake), CMakeLists.txt (for CMake), or a .pro file (for qmake), then invokes the command to update the project's Makefile, then builds the project associated with each library in the project, and finally invokes the actual "Build (via make)" task.

The tutorial provides a step-by-step introduction to this procedure when using makemake. Once you understand this, you should study the help section on compiling.

The Config button in the upper right corner of the Project window opens the Make.header file (for makemake), the CMake.header (for CMake), the QMake.header file (for qmake), or the Makefile (for the manual option).

As mentioned above, you can add libraries to the project. (static or shared, as specified in the Edit File Types dialog) When using makemake, these will be included in Make.files as dependencies. Unfortunately, make is not powerful enough to recognize .so.<vers>, so Code Crusader doesn't recognize it either. To get a pure .so file, either create a symbolic link or place the version number in front of the .so suffix. (The latter is preferred because then there is never any confusion at link time.)

Note that the directories that you specify in the Search Paths dialog are not passed to the compiler because every compiler has a different way of handling this. If you are using makemake, you have to edit Make.header to modify SEARCHDIRS. If you are using CMake, you have to edit CMake.header to modify the INCLUDE_DIRECTORIES() command. If you are using qmake, you have to edit QMake.header to modify INCLUDEPATH.

Notes on CMake

If you want to use the platform specification features of CMake, then you must invoke them by hand in CMake.header. Define a variable (e.g., MY_OS_FILES) within an IF ... ELSE ... ENDIF block and add this variable (e.g., ${MY_OS_FILES}) in the "Expression to append to list of dependencies" in the Project Configuration dialog.

Notes on qmake

Since qmake requires a list of both source and header files, Code Crusader attempts to build the list of header files automatically. However, only header files that directly correspond to source files in the project will be included. If you have additional header files, or if you place your header files in a different directory than your source files, you will have to explicitly add these header files to the project if you want them to be included in the .pro file.

If you want to use the platform specification features of qmake, then you must invoke them by hand in QMake.header. Use -= to remove files from the list and += to add files to the list.

Since qmake is a generic utility, the default configuration in QMake.header does not include anything specific to Qt. If you want to use qmake to build Qt programs, you need to add qt to the line that begins with CONFIG.

Configuring the project

The following options can be changed in the Project Configuration dialog:

Maintain Makefile by hand
Generate Make.files from files in Project window
Generate CMake input file from files in Project window
Generate qmake input file from files in Project window
These options control whether Code Crusader lets you maintain your own Makefile or uses makemake, CMake, or qmake.
Target name
This is the name of the program or library to be built. If you are using makemake, it can also be a list of names separated by commas. All names will be built using the same set of source files, so this is mainly useful for generating both static and shared versions of a library.
Expression to append to list of dependencies in Make.files
This expression can do anything that make allows: evaluate variables, invoke functions, etc. This is useful for conditional or variable dependencies.
Command to update this project's Makefile
This command is used to re-build the Makefile when files are added to or removed from project. It can also be invoked directly by using the "Update Makefile" item on the Project menu in the Project window.
Command to build this project when used by other projects
If project A depends on project B, this command is used to automatically build project B when you ask Code Crusader to build project A.

Preferences

The following options can be changed in the Project Preferences dialog:

Reopen text files when project is opened
If this is checked, the files that were open when the project was closed will be reopened the next time you open the project.
Update symbol database while compiling
If this is checked, Code Crusader will update all affected inheritance trees and symbol browsers while you build a project or compile a source file.
Double space compiler output
If this is checked, Code Crusader separates each line of compiler output with a blank line. This often makes it much easier to read.
Rebuild Makefile daily to update dependencies
If this is checked, Code Crusader will re-build the Makefile once a day, even if you have not added files to or removed files from the project. This is very useful because it updates the list of header files on which each source file depends.
Path type to use when adding files via Drag-And-Drop
If "Ask when files are dropped" is selected, the other options will be presented in a dialog when you drop files on a project. Otherwise, the selected path type will be used.

Choosing your text and binary editors

You can use the "External editors..." item on the Preferences menu to set which text and binary editors to use when displaying files. For the text editor, the common choices are:

  1. built-in editor
  2. emacs:
    emacsclient $f
    emacsclient +$l $f
    (you must also run M-x server-start from within emacs)
  3. vi:
    xterm -title "$f" -e vi $f
    xterm -title "$f" -e vi +$l $f
For the binary editor, the choices are:
  1. emacs:
    If you install the full remote control package (not just emacsclient), you can tell emacs to open a file via the hexl-find-file command.
  2. vi:
    xterm -title "$f" -e vi $f

If a character is preceded by a backslash, the backslash is removed and any special meaning is ignored. Thus, use \$ to get a dollar character and \\ to get a backslash character.

The advantages of using the built-in text editor are explained in the Text Editor help section.


Project Tutorial

This tutorial will walk you through the steps required to create and run the famous Hello World program in C++ using the GNU C++ compiler. The basic steps are the same for other compilers and languages. Refer to the end of this tutorial for notes on other languages.

Creating the project

  1. Select "New project..." from the File menu.
  2. In the Save File dialog, go to the directory where you want to save the project files. (usually a new, empty directory)
  3. Specify the name of the project as hello_world.jcc
  4. Select "None" from the Project Template menu.
  5. Set the method of generating the Makefile to "via makemake"
  6. Click the Save button.

This creates the project file hello_world.jcc along with the text files Make.header and Make.files. You will learn how to edit Make.header later in this tutorial. Make.files will be automatically rewritten for you based on the contents of the Project window. These two files will be used by makemake to create Makefile which will in turn be used to compile your program.

Configuring the project

  1. Select "Edit project configuration..." from the Project menu in the Project window.
  2. Change the target name to hello_world.
  3. Click the OK button.

Since this is a C++ project, you need to link the standard C++ library to your program:

  1. Click the Config button in the upper right corner of the Project window to open Make.header.
  2. Add -lstdc++ in front of -lm on the line that begins with LOADLIBES.

You need to learn at least the basics of GNU make in order to fully understand the contents of Make.header. You do not have to do this in order to complete this tutorial, however.

Creating your program

  1. Select "New text file" from the File menu to get a Text Editor window.
  2. Drag, paste, or type the following text into the Text Editor window:
  3. #include <iostream>
    using namespace std;
    
    int main(int argc, char* argv[])
    {
    	cout << "Hello world!" << endl;
    	return 0;
    }
    
  4. Select "Save" from the File menu and save the file as hello_world.cc

argc is the number of command line arguments. argv contains the command line arguments, starting with argv[0] which is the name of the program. The return value is used by shell scripts to determine success or failure. Returning zero indicates success.

Notice that once you saved file, context-sensitive highlighting became active and the Functions menu appeared in the menu bar. This is because the suffix ".cc" tagged it as a C++ source file.

Building the project

  1. Select "Relative to project file" from the "Add to project: hello_world" menu on the Tasks menu in the Text Editor window.
  2. Select "Build & Run" from the Tasks menu in the Text Editor window.

The first window shows the result of compiling and linking your program. The second window shows the result of running your program.

Using the Symbol Browser

Now that the project has been built, the Symbol Browser window will display the reference to your function, main(). If you double-click on the function name, Code Crusader will open the source file to display the function.

When you add functions, classes, static variables, preprocessor defintions, etc. to your program, these will all show up in the Symbol Browser window once you either build the project or use the "Update" item on the Symbol menu. Note that function declarations (prototypes) are displayed in italics to distinguish them from function definitions.

Where to go from here

Now that you have successfully compiled and run a simple project, the possibilities are endless. This can be both a blessing and a curse.

The following sub-sections discuss how to create libraries and projects for other languages. Once you have read this information, we suggest that you study the full on-line documentation for working with Code Crusader projects.

O'Reilly publishes books on a wide variety of programming languages. These cover both general programming practices and philosophy and specific issues for C/C++ programmers.You can learn more about make either by reading books published by O'Reilly, such as Programming with GNU software and Managing projects with make, or by studying the on-line documentation for GNU make.

The documentation for makemake is included in this on-line help.

Organizing your projects and source code

Each project must be placed in a separate directory to prevent the Makefiles from interfering with each other.

The simplest way to manage the source code for a project is to put all the files in a subdirectory of the project directory and then use groups in the Project window to organize the files. However, since organization is largely a personal preference, Code Crusader does not place any restrictions on the arrangement of the source files in a project.

Creating libraries

To build a library instead of a program, all the steps are the same except:

Any language that compiles to .o files can be used when writing a library: C, C++, FORTRAN, Assembly, etc. You can even mix them together, i.e., write one source file in C, another in Assembly, etc.

Java

If you use Java, all the steps are the same except:

In general, you need to change the Run task to either appletviewer my_java_applet.html or java my_java_program, depending on whether you are writing an applet or a program.

FORTRAN

If you use FORTRAN, all the steps are the same except:

Building multiple versions of a program

Often, one requires multiple versions of a single program. The most common example is Debug and Release versions. The easiest way to do this is to let Code Crusader build the Debug version and then create a separate Release build target in the Makefile that builds the Debug version and then runs strip:

.PHONY: release
release: my_program
	@cp my_program my_program_release
	@strip my_program_release

A more sophisticated method is described here. This method is useful if one must build the release version with a higher compiler optimization level than the debug version, or if one wants only the shared version of a library to be compiled with position independent code.


Template files

Project templates

The "Save as template..." item on the File menu in the Project window lets you create a template from the current project. It will save all the project settings, including Make.files, Make.header, CMake.header, QMake.header, .pro file, Makefile, the search paths, the Tasks menu, and the C preprocessor configuration. It will also save the contents of all the files in the project that are in the project directory or in directories below the project directory. (i.e. files that are specified as ./something) These files will be recreated automatically when the project template is used. When creating a template, you can add other files to the project window as well, but it usually only makes sense to include files relative to the root directory (/) since these will always be there.

Project templates must be stored in ~/.jxcb/project_templates/. When you create a template, the Save File dialog will automatically display this directory. When creating a project, Code Crusader will automatically let you choose a template from this directory, if the directory exists.

If you want a particular template to be available to all Code Crusader users, place it in /usr/lib/jxcb/project_templates/. When creating a project, Code Crusader will automatically include templates in this directory in the menu of available project templates.

Project wizards

There are actually two different types of files that can be placed in the Code Crusader project template directory. The first is the type discussed above. The second type is a wizard interface. A wizard is a program that will create a customized project after asking you for the relevant information. The format of a wizard interface file is:

jx_browser_project_wizard
0
command to run the wizard program

The zero on the second line is the version number. The command on the third line can run an arbitrary program, but it must be a single command, not a sequence of commands separated by semicolons. (For this case, use a separate shell script.) In the command, $path will be replaced by the directory in which the user wants to create the project, and $name will be replaced by the name of the project.

The wizard must notify Code Crusader when it is finished by invoking Code Crusader (jcc) with the full path and name of the project file that has been created. (i.e. just as if the user had requested to open the project via the command line) If an error occurs in the wizard, it is the wizard's responsibility to report it.

Text file templates

The "Save as template..." item on the File menu in the Text Editor window lets you create a template from the text in the window. You can use the template by selecting the "New text file from template..." item from the File menu in any window. This creates a new Text Editor window containing the template's text. You can then use Search & Replace and macros to fill in the template.

Text file templates must be stored in ~/.jxcb/text_templates/. As with project templates, Code Crusader automatically displays this directory when you create or wish to use a text file template.


Compiling your program

Introduction to compiling under UNIX

Development environments on the Macintosh (e.g. Metrowerks) and on Windows (e.g. Visual C++) hide the process of compiling the source files and building the finished program. They are able to do this because the project manager, compiler, and linker are all integrated into one system.

On UNIX, however, the compiler and linker are separate programs, and different people and different platforms (e.g. Linux vs Solaris) prefer to use different compilers and linkers. Thus, while Code Crusader and makemake do hide most of the work done by a project manager, they do not hide the details of dealing with the compiler and linker.

If a C program is contained entirely within one source file and does not require any header files other than those in /usr/include, one can compile and link it with the following command:

gcc -o program_name source_file.c

A C++ program that is contained within one source file can be compiled and linked with:

g++ -o program_name source_file.cc

If you have GNU's version of make, you can use:

make source_file

in place of either of the above commands.

For a program that is spread across more than one source file, you need to learn how to use either makemake and GNU's version of make or cmake. makemake is included as part of the Code Crusader package. You can learn more about make either by reading books published by O'Reilly, such as Programming with GNU software and Managing projects with make, or by studying the on-line documentation for GNU make.

Compiling with Code Crusader

In order to compile anything, you must first create or open a project. You can create a new project by using the "New project..." item on the File menu. The tutorial walks you through the basics of creating a project and compiling and running a very simple program. Once you have mastered these basics, you can get as fancy as you want by adding build targets to Make.header and defining your own tasks on the Tasks menu.

The basic tasks for compiling a program are automatically included on the Tasks menu. These are:

Build (via make)
Compiles and links your program.
Compile source file (via make)
From an Editor window, compiles the source file. From any other window, compiles the selected source files or classes.
Remove object files (make tidy)
Deletes compiler output files to free up space on your disk.

The command to build a Makefile for the project is specified in the Project Configuration dialog.

The output of the compile process is displayed in an editor window, so you can use Control-double-click to open a file (line numbers are also parsed, e.g. /usr/include/stdio.h:35) and also edit and save the output.

While the compile process is running, you can pause it by pressing the Pause button in the upper right corner or by pressing Control-Z, just like on the command line. You can stop it by pressing the Stop button in the upper right corner or by pressing Control-C (as on the command line) or Meta-period (for Macintosh fans). You can use the key shortcuts even when the window is iconified. (Note that, while the window is iconified, the *** in the window title tells you that the compile is running. If errors are found, this changes to !!!.)

If the compiler reports errors, the Errors menu in the Compiler Output window will become active. This lets you jump from one error to the next. For convenience, if you haven't already started looking at the errors, the first error is hilighted when the process finishes. You can examine the errors before the compile finishes because the Errors menu becomes active as soon as the first error is detected. To open the file containing an error, you can either Control-double-click on the file name or use "Open selection to error" on the Errors menu.

When the compile is finished and errors have occurred, the window will be de-iconized if it is iconized but will not be raised otherwise. This allows users who prefer a single virtual screen to be notified by having the window de-iconize and allows users who prefer multiple virtual screens to avoid having the window appear on their current screen by leaving it de-iconized on another virtual screen.


Running and debugging your program

In order to run anything, you must first create or open a project. You can create a new project by using the "New project..." item on the File menu. The tutorial walks you through the basics of creating a project and compiling and running a very simple program. Once you have mastered these basics, you can get as fancy as you want by defining your own tasks on the Tasks menu to run or debug your program with different sets of command line arguments.

The basic tasks for running and debugging a program are automatically included on the Tasks menu. These are:

Run
Runs your program in an Editor window so you can search and save the output.
Debug
Runs your program in a debugger.
Set breakpoint in debugger
From an Editor window, sets a breakpoint at the selected line in a debugger. From any other window, opens the selected files or classes in a debugger.
Open source file in debugger
From an Editor window, opens the file in a debugger. From any other window, opens the selected files or classes in a debugger.

Code Medic is the default debugger. You can change this by editing the Tasks menu. Please note that other debuggers may not provide the same features, e.g., setting a breakpoint when the debugger is already running.

For your convenience, the following tasks are also provided by default:

Build & Run
Compiles, links, and runs your program in an Editor window so you can search and save the output.
Build & Debug
Compiles, links, and runs your program in a debugger.

While your program is running, you can pause it by pressing the Pause button in the upper right corner or by pressing Control-Z, just like on the command line. You can stop your program by pressing the Stop button in the upper right corner or by pressing Control-C (as on the command line) or Meta-period (for Macintosh fans). If your program refuses to respond to the Stop button, you can kill your program by pressing the Kill button in the upper right corner. You can use the key shortcuts even when the window is iconified. (Note that, while the window is iconified, the *** in the window title tells you whether or not the program is running.)

The input field at the bottom of the window lets you send text to the running process. Simply type the text and press Return. The EOF button sends end-of-file to the process. You can also use Control-D, as on the command line.

If you run your program in an Editor window, and the program terminates abnormally, Code Crusader will beep and display the reason in the Editor window.

If you run your program in a debugger, you must remember that if you have modified the source file, then the line numbers in Code Crusader will not match those used by the debugger, and confusion will ensue. A good strategy is to never save your source files until you are ready to compile again. With this method, you will never forget which files have been modified. You can view the version of the source code that was compiled into the binary by opening the source file in the debugger.


Symbol Browser

If you have Universal ctags on your execution path, the symbol browser will display a list of all the symbols in all the source files in the project and on the project's search paths.

Purpose of the Symbol Browser

The Symbol Browser is primarily intended to work behind the scenes because it is simply an alphabetized list of all symbols that have been defined. The real power of the Symbol Browser lies in its connection to the Text Editor. When you Meta-double-click on a symbol in a Text Editor window, Code Crusader searches the list of symbols:

Code Crusader also attempts to narrow down the appropriate choices by using context. If the name of the source file displayed in the Text Editor window matches a known class name, only symbols defined by this class and its ancestors will be considered. Since this is sometimes inappropriate, you can use Meta-Shift-double-click to avoid context sensitivity.

Using the Symbol Browser

To locate a particular symbol, press the space bar and then type the first few letters in its name. This search is case-insensitive. To open the file to show the symbol's definition, press Return or double-click it. You do not have to de-iconify the window before typing.

Since both a function's declaration and its definition are included in the list of symbols, the declaration is italicized so you can tell the difference.

If a symbol is defined within a namespace (i.e. not at global scope), both the fully qualified version and the unqualified version will be displayed in the list, though at very different positions since the symbols are alphabetized. If a symbol is defined in more than one namespace, incremental search by typing will find the unqualified version (unless you type the entire namespace, too). To display a list of the fully qualified versions so you can choose the one you want, hold down the Meta key and double click on the unqualified symbol name, just like in the Text Editor window (see above).

Preferences

The following options can be changed in the Symbol Preferences dialog:
Raise class inheritance trees when searching with right mouse button
If this is checked and you right-double-click on a symbol in a Text Editor or the Symbol Browser, the class inheritance trees that find a match will automatically show themselves. If this is not checked, you can show the trees by using the items on the Actions menu in the window that displays the search results.

File List Window

This window is available via the "Show file list" item on the Project menu in all the windows related to a project. It displays every file on the project's search paths that matches a suffix type from the list of types in the File Types dialog.

To find a particular file in the list, simply type the first few characters of its name.

To display a subset of the files, you can use either a wildcard filter, which works just like file globbing on the command line (i.e., ? for a single unknown character, and * for more than one unknown character), or a regular expression.

To display a file in a file manager, use the "Show selected files in file manager" item on the List menu. The command that is used is determined by the "File manager preferences..." item on the Preferences menu.


C++ Class Tree

The tree displays the inheritance relationships between the C++ classes that are found by parsing header files. Green indicates public inheritance, yellow is protected inheritance, and red is private inheritance. For the primary parent, black is used to indicate public inheritance to avoid too many distracting colors and make the protected and private inheritances stand out more.

Classes that are declared with "class" are drawn with black text. Classes that are declared as "struct" or "enum" are drawn with gray text. The names of classes that declare pure virtual functions are italicized.

If the parent of a class is not found in any of the files that are parsed, a "ghost" class is created to indicate this. Ghost classes are drawn with a gray background.

To add classes to the tree, use the "Add classes..." item on the Tree menu. (Classes in the Project window are always included in the tree.) To update the current tree without quitting, use the "Update" item. The "Edit file types..." item lets you set the suffixes for source and header files. It is a good idea to add all the directories that contain source or header files, not just those that contain classes. This way, when Code Crusader searches for a file (e.g. when you use "Open selection" in a Text Editor window), it is more likely to find it. (Note that /usr/include is always searched.)

To locate a particular class, press the space bar and then type the first few letters in its name. This search is case-insensitive and ignores the namespaces. To then open the source file, press Return. To open the header file, press Ctrl-Tab. You do not have to de-iconify the window before typing.

To display a list of all the functions implemented by a class, right-double-click the name or first select the name and then select "Open function list" from the Tree menu.

To locate all classes that implement a particular function, select "Find function" from the Tree menu and then enter the name of the function to search for. This is case sensitive. If a single function is found, its definition will automatically be displayed.

If you click on a class in the Tree window:

Any button once (or type the first few characters of the name)
Select the class
Shift key + any button once
Select/deselect the class without deselecting other classes
Left button twice (or Return)
Open source file for the class
(opens documentation file if source can't be found)
Middle button twice (or Ctrl-Tab)
Open header file for the class
Right button twice
Open list of functions implemented by the class

There are also several shortcuts in the built-in editor that connect back to the tree.

Preferences

See the Tree Preferences section.

Defining preprocessor symbols

Code Crusader can never automatically know which preprocessor symbols that are defined at compile time. In order to parse header files correctly, however, it does need to know the definitions of the symbols used in your class definitions. You can specify these using the "Preprocessor macros..." item on the Preferences menu.

As an example, the ACE networking library defines classes with

class ACE_Export class_name {...}

On Windows, ACE_Export evaluates to the compiler dependent stuff required to build a DLL. On UNIX, it evaluates to nothing, so it simply disappears. Code Crusader requires that you define ACE_Export to evaluate to nothing, because otherwise the parser will not recognize it as a class definition.

This implementation is not a true preprocessor. It can handle only simple names, not full macros with arguments. This is generally sufficient because only macros in the class declaration need to be defined, and as above, they usually only need to be removed. If this is not sufficient, please contact the author.

Code Crusader can, however, replace a macro that takes arguments with a fixed string. As an example, the Qt widget library defines the macro Q_PROPERTY(...). This confuses Code Crusader's parser, but defining Q_PROPERTY() to be replaced by nothing (i.e. removed) is sufficient to allow Code Crusader to parse the rest of the file.


D Class Tree

The tree displays the inheritance relationships between the D classes and interfaces that are found by parsing source files.

The names of interfaces are italicized.

If a class or interface is referenced but never defined in any of the files that are parsed, a "ghost" is created to indicate this. Ghosts are drawn with a gray background.

To add classes and interfaces to the tree, use the "Add classes..." item on the Tree menu. (Classes and interfaces in project files are always included in the tree.) To update the current tree without quitting, use the "Update" item. The "Edit file types..." item lets you set the suffixes for source files.

To locate a particular class or interface, press the space bar and then type the first few letters in its name. This search is case-insensitive and ignores the namespaces. To then open the source file, press Return. You do not have to de-iconify the window before typing.

To display a list of all the members in a class or functions in an interface, right-double-click the name or first select the name and then select "Open function list" from the Tree menu.

To locate all classes and interfaces that include a particular function, select "Find function" from the Tree menu and then enter the name of the function to search for. This is case sensitive. If a single function is found, its definition will automatically be displayed.

If you click on a class or interface in the Tree window:

Any button once (or type the first few characters of the name)
Select the item
Shift key + any button once
Select/deselect the item without deselecting other items
Left button twice (or Return)
Open source file for the item
Right button twice
Open list of members or functions in the item

There are also several shortcuts in the built-in editor that connect back to the tree.

Preferences

See the Tree Preferences section.


Go Struct & Interface Tree

The tree displays the composition relationships between the Go structs and interfaces that are found by parsing source files.

The names of interfaces are italicized. If an interface or struct is not exported, its name will be gray.

If a struct or interface is referenced but never defined in any of the files that are parsed, a "ghost" is created to indicate this. Ghosts are drawn with a gray background.

To add structs and interfaces to the tree, use the "Add structs/interfaces..." item on the Tree menu. (Structs and interfaces in project files are always included in the tree.) To update the current tree without quitting, use the "Update" item. The "Edit file types..." item lets you set the suffixes for source files.

To locate a particular struct or interface, press the space bar and then type the first few letters in its name. This search is case-insensitive and ignores the namespaces. To then open the source file, press Return. You do not have to de-iconify the window before typing.

To display a list of all the members in a struct or functions in an interface, right-double-click the name or first select the name and then select "Open function list" from the Tree menu.

To locate all interfaces that include a particular function, select "Find function" from the Tree menu and then enter the name of the function to search for. This is case sensitive. If a single function is found, its definition will automatically be displayed.

If you click on a struct or interface in the Tree window:

Any button once (or type the first few characters of the name)
Select the item
Shift key + any button once
Select/deselect the item without deselecting other items
Left button twice (or Return)
Open source file for the item
Right button twice
Open list of members or functions in the item

There are also several shortcuts in the built-in editor that connect back to the tree.

Preferences

See the Tree Preferences section.


Java Class Tree

The tree displays the inheritance relationships between the Java classes that are found by parsing source files.

The names of interfaces, classes that are declared abstract, and classes that declare abstract functions are italicized. If an interface or class is not declared public, its name will be gray. If an interface or class is declared final, its name will be boldfaced.

If the parent of a class is not found in any of the files that are parsed, a "ghost" class is created to indicate this. Ghost classes are drawn with a gray background.

To add classes to the tree, use the "Add classes..." item on the Tree menu. (Classes in the Project window are always included in the tree.) To update the current tree without quitting, use the "Update" item. The "Edit file types..." item lets you set the suffixes for source files. It is a good idea to add all the directories that contain source files, not just those that contain classes. This way, when Code Crusader searches for a file (e.g. when you use "Open selection" in a Text Editor window), it is more likely to find it.

To locate a particular class, press the space bar and then type the first few letters in its name. This search is case-insensitive and ignores the namespaces. To then open the source file, press Return. You do not have to de-iconify the window before typing.

To display a list of all the functions implemented by a class, right-double-click the name or first select the name and then select "Open function list" from the Tree menu.

To locate all classes that implement a particular function, select "Find function" from the Tree menu and then enter the name of the function to search for. This is case sensitive. If a single function is found, its definition will automatically be displayed.

If you click on a class in the Tree window:

Any button once (or type the first few characters of the name)
Select the class
Shift key + any button once
Select/deselect the class without deselecting other classes
Left button twice (or Return)
Open source file for the class
(opens documentation file if source can't be found)
Right button twice
Open list of functions implemented by the class

There are also several shortcuts in the built-in editor that connect back to the tree.

Preferences

See the Tree Preferences section.


PHP Class Tree

The tree displays the inheritance relationships between the PHP classes that are found by parsing source files.

The names of interfaces, classes that are declared abstract, and classes that declare abstract functions are italicized. If an interface or class is declared final, its name will be boldfaced.

If the parent of a class is not found in any of the files that are parsed, a "ghost" class is created to indicate this. Ghost classes are drawn with a gray background.

To add classes to the tree, use the "Add classes..." item on the Tree menu. (Classes in the Project window are always included in the tree.) To update the current tree without quitting, use the "Update" item. The "Edit file types..." item lets you set the suffixes for source files. It is a good idea to add all the directories that contain source files, not just those that contain classes. This way, when Code Crusader searches for a file (e.g. when you use "Open selection" in a Text Editor window), it is more likely to find it.

To locate a particular class, press the space bar and then type the first few letters in its name. This search is case-insensitive and ignores the namespaces. To then open the source file, press Return. You do not have to de-iconify the window before typing.

To display a list of all the functions implemented by a class, right-double-click the name or first select the name and then select "Open function list" from the Tree menu.

To locate all classes that implement a particular function, select "Find function" from the Tree menu and then enter the name of the function to search for. This is case sensitive. If a single function is found, its definition will automatically be displayed.

If you click on a class in the Tree window:

Any button once (or type the first few characters of the name)
Select the class
Shift key + any button once
Select/deselect the class without deselecting other classes
Left button twice (or Return)
Open source file for the class
(opens documentation file if source can't be found)
Right button twice
Open list of functions implemented by the class

There are also several shortcuts in the built-in editor that connect back to the tree.

Preferences

See the Tree Preferences section.


Class Tree Preferences

The following options can be changed in the Tree Preferences dialog:

Font size
This menu lets you change the font size used in the Tree and Function List windows.
Raise window if search matches single class
If there is only one match when you Meta-dbl-click in an editor window, it is usually less disruptive if only the source file containing what you are looking for is displayed. This will be the case if this item is not checked.
Automatically minimize MI link lengths
If this is checked, the multiple inheritance link lengths will be minimized every time the class tree is changed. If this is not checked, you can use the "Minimize MI link lengths now" item on the Tree menu to do it when needed. This option is provided because the optimal algorithm is exponential so it can take a long time if you make heavy use of multiple inheritance.
Draw MI links
Multiple inheritance links are much easier to follow if they are drawn on top of everything else. However, sometimes it is better to drawn them underneath to minimize the clutter.

Task menu reference

Performing a task

The "Perform one-off task..." item allows you to execute one or more commands in an Editor window. The syntax is the same as in a terminal window, including chaining multiple commands by separating them with semicolons, except that if you want to use shell specific functions such as loops or environment variable expansion, you must explicitly invoke the shell of your choice, e.g., /bin/bash -c my_program

You can perform as many tasks as you wish simultaneously. Each time you start a new task, it either re-uses an existing, inactive window or creates a new one. Each window title contains the name of the task so you can identify each one. If you save the output of a task to a file, the window will not be re-used again.

Code Crusader provides many useful variables that you can use in your tasks to make them usable in any project or on any file:

$project_path
Absolute path to project file
$project_name
Name of project (without .jcc suffix)
$program
Target name entered in Project Configuration dialog
$full_name
Full path and file name
$relative_name
Project-relative path and file name
$file_name
File name
$file_name_root
File name root (e.g. file.c -> file)
$file_name_suffix
File name suffix (e.g. file.c -> .c)
$full_path
Full path to file
$relative_path
Project-relative path to file
$line
Current line number in file

If a character is preceded by a backslash, the backslash is removed and any special meaning is ignored. Thus, use\$ to get a dollar character and \\ to get a backslash character.

If you want to perform a task on a file, and you want the task to execute in the directory that contains the file, then enter "@" as the path. This is especially useful for version control tasks.

There are many options that you can specify when performing a task:

This task invokes make
If this option is checked, then the Makefile is checked to see if it needs to be updated before the task is performed, a Compiler Output window is used to display the results from the task, and error messages are hilighted.
Save all files before executing
If this option is checked, the contents of all Editor windows will be saved before the task is performed. You must check this option for any task that is supposed to operate on a file!
Run on one file at a time (cannot yet be turned off)
If this option is checked, the task is performed once for each file that is selected in the window. This applies to any window where multiple files can be selected at the same time.
Display output in window
If this option is checked, an Editor window will be created to display the output from the task. Otherwise, the task's output will appear in the terminal window, if any, from which you started Code Crusader. When you use an Editor window to display the output of a task, you will not be able to quit Code Crusader until the task is finished.
Raise window before executing
Code Crusader re-uses existing task output windows when possible. If this option is checked, a window that is about to be re-used will be brought to your attention before the task begins executing.
Beep when execution is finished
If this option is checked, Code Crusader will beep to notify you that a task is finished.

If you find yourself performing the same task over and over again, you can use the "Save in menu" menu to add the task to the Tasks menu so you do not have to use the Perform Task dialog again.

Customizing the Tasks menu

The "Customize this menu..." item opens a dialog that lets you specify what the Tasks menu looks like and the command that each menu item executes. The top list displays the tasks that are always available, regardless of which project you have open. The bottom list displays takss that are only available when the specified project is the active one. This allows you to specify both tasks that are generic and usable with all projects (e.g., compiling) and tasks that are specific to individual projects (e.g., running a program with a particular set of command line arguments).

To edit a text item, double click on it. To change the options for a task, click in the cell to get a menu of the available options.

The menu text and menu shortcut are displayed when the menu is opened. The menu text can be anything you want. If you leave it blank, the text of the command will be displayed. The menu shortcut can include any combination of the following prefix modifiers:

If you choose a menu shortcut that is already being used for an item on another menu, then the shortcut will not appear on the Tasks menu. If you prefer that the shortcut be used on the Tasks menu instead, you can remove the original assignment by editing the menu_strings file that came as part of the Code Crusader distribution.

A bold line between rows indicates that a separator will be displayed between the corresponding items on the menu. To change this setting, click in the Options column.

To rearrange items, simply click and drag. This works both within a list and between lists. To move (rather than copy) an item from one list to the other, hold down the Meta key while you drag the item.

The command to execute, the options, and the directory are exactly the same as in the Perform Task dialog described above.

The name of the task is the name that can be used to call the task from other tasks via the & notation, e.g., the task &make_default calls the task whose name is "make_default". You cannot specify arguments when you call another task.

The command to rebuild dependencies cannot invoke subroutines with the & notation. This command is the same one displayed in the Edit Project Configuration dialog. You can manually invoke this command via the "Update Makefile" item on the Project menu in the Project window.


Viewing man pages

The Man Pages dialog lets you specify what function to look up and which section to look in. If you leave the section blank, the system will search all sections.

To search the man pages for all occurrences of the function, check the Apropos checkbox.

You can get the Man Pages dialog via the "Look up man page..." item on the Search menu in the Text Editor window and the Project menu in the Project and Symbol windows and any Class Tree window. Man pages are initially read-only.

In the Text Editor window, Meta-double-click checks the UNIX man pages if it can't find the function name in the class tree. Meta-double-click also understands the apropos format "name (#)" and automatically looks in the correct section.

The following command line options are provided so you can alias "man" to "jcc --man" and "apropos" to "jcc --apropos" whenever you are running X:

--man
displays Man Page dialog
--man page_name
displays man page
--man section_name page_name
displays man page from given section
--man -k search_string
--apropos search_string
displays list of relevant man pages

Specifying File Types

The "File types..." item on the Preferences menu lets you define how you want to deal with each text file that you open. A file can be recognized either by the file name suffix (e.g. .txt), a file name pattern (e.g. core.*), or a regular expression that matches the beginning of the file's contents. Once the file is recognized, the attributes that you specified in the table are attached to the associated Text Editor window.

If the text in the "Suffix / Regex" column begins with an up caret (^), it is interpreted as a regular expression. Otherwise, it is assumed to be a file suffix. (This usually starts with a period, but it doesn't have to.) The file's type is recalculated every time you save it, so a type based on the content will not be recognized in a brand new file until the file is saved for the first time.

Clicking in the "Type" column displays a fixed menu of choices that are linked to built-in features:

Clicking in the "Macro set" column displays a menu of all the macro sets defined in the associated dialog.

Clicking in the "Script path" column displays a menu of all the directories in /usr/lib/jxcb/scripts/ and ~/.jxcb/scripts/. Since there may be a directory with the same name in both places, they are marked as "(global)" and "(personal)", respectively. Refer to the External Scripts help section for information on how the script path is used.

Similarly, clicking in the "CPM rules" column displays a menu of all the Clean Paragraph Margins rule sets defined in the associated dialog.

Clicking in the "Word wrap" column toggles the value between Yes and No. This controls whether or not lines are wrapped if they extend beyond the right edge of the Text Editor window. Holding down the Meta key while clicking the mouse toggles the value and sets the entire column to the new value.

If the file type is External, the "Open command" column will be editable. When you use $f in this command, it will be replaced by the full path and name of the file to be opened.


Text Editor

Code Crusader can read UNIX, Macintosh, and DOS/Windows text files. Each file's format is indicated on the "File format" submenu on the File menu. To convert a file to a different format, simply select the desired format from this menu and then save the file.

When a file is opened, Code Crusader automatically detects the indentation method (spaces or tabs) and, if the method is "spaces," adjusts the tab width to match. If the file uses mixed indentation, whitespace is made visible. (This is especially useful when editing Makefiles, which interpret spaces and tabs differently.)

When a file name in the Windows menu is red, it means that the file has been modified and needs to be saved. This is also shown by drawing three asterisks to the left of the window title.

By default, Code Crusader follows the Macintosh clipboard model. This means that text is not automatically copied when it is selected. Instead, it is only copied when you use the "Copy" item on the Edit menu or Meta-C. The main advantage of this model is that paste can then replace the selected text. If you prefer the X clipboard model, the Preferences dialog lets you use this instead. Either way, the clipboard is persistent, so if you copy text in a Text Editor window and then close the window, you can still paste the text later on.

Drag-And-Drop

When Drag-And-Drop is enabled in the Text Editor Preferences dialog, you can:

If the text will be copied when dropped, a small plus (+) will be displayed in the cursor. If the dialog will be displayed when the text is dropped, a small question mark (?) will be displayed in the cursor.

Drag-And-Drop has the disadvantage that that you cannot click and drag in the selected text to make a new selection. Some people find that this slows them down while editing.

Holding down the Meta key toggles the Drag-And-Drop setting. This allows you to get the other behavior when you need it. (Once you begin dragging, you can release the Meta key so that you can move the text. This trick also works in all text input fields.)

Drag-And-Drop can be cancelled by pressing the Escape key before releasing the mouse button.

The underlying X protocol is XDND.

Balancing grouping symbols

The "Balance closest grouping symbols" item on the Search menu searches for the closest pair of grouping symbols ((), {}, []) that enclose either the caret or the current selection and selects the text between this pair of grouping symbols. Repeated use of this menu item expands the selection outward to the next pair.

The one special case is that, if you select a single grouping symbol, this menu item will attempt to balance that symbol instead of treating it like a normal selection.

This feature is useful when trying to check a complicated expression containing many nested pairs of parentheses. It is also useful for block indenting since it can instantly select all the text between a pair of braces.

Note that the algorithm does not use a lexer to balance the grouping symbols, so it will fail when grouping symbols are used inside character and string constants.

Editing source code

If you have Universal ctags on your execution path, Code Crusader will automatically display an additional menu in the menu bar listing all the functions defined in the file. When you select a function from this menu, the text scrolls to display that function's definition. In the Preferences, you can choose whether to display the function names alphabetically or in the order defined in the file. With the latter configuration, a horizontal line is drawn on the menu to indicate the location of the caret in the file. If you want to momentarily display the functions in the opposite order, hold down the Meta key while opening the menu.

Editing HTML

The Web Browser Preferences dialog lets you specify the commands for viewing files and URL's in the browser of your choice. The default is to use Firefox:

firefox $u
Used when you press the View button in the upper right corner of the window.
firefox file:'$f'
Used when you Control-double-click on a URL.

You can use any other browser, if you can figure out the commands to execute. "$f" is replaced by the full path and file name when it is used in the command to view a file, while "$u" is replaced by the URL name when it is used in the command to view a URL. If a character is preceded by a backslash, the backslash is removed and any special meaning is ignored. Thus, use\$ to get a dollar character and \\ to get a backslash character.

Mouse shortcuts

Left clicking positions the insertion caret. Left clicking and dragging selects the characters that you drag across. Left double clicking selects the entire word under the cursor. If you drag instead of releasing after the second click, the selection will extend one word at a time. Left double clicking while holding down the partial word modifier (adjustable in the Preferences dialog) selects the partial word under the cursor and dragging extends the selection by one partial word at a time. Left triple clicking selects the entire line, and dragging extends the selection by a line at a time.

Holding down the Shift key while left clicking or simply right clicking extends the selection in the same way that the original selection was performed, i.e. if the original selection was one word at a time, the extended selection will also be one word at a time.

Middle clicking pastes the current contents of the clipboard at the position where you click.

If Drag-And-Drop is turned on in the Preferences, left clicking on the current selection and dragging lets you drag the selected text instead of selecting text.

Additional shortcuts:

The double click shortcuts activate when you release the mouse button, so you can select more than a single word. This is useful for strings like "std::ios".

Key shortcuts

The arrow keys move the caret around inside the text. Holding down the Control key makes the up and down arrows move the caret to the top and bottom of the visible text, respectively, while the left and right arrows move the caret by one word at a time. Control-up/down is useful for scrolling the text by one line without having to use the scrollbar: simply press Control-up/down-arrow and then up/down. It is also useful for bringing the cursor to the visible text after scrolling.

Holding down the partial word modifier key (settable in the Preferences dialog) makes the left and right arrows move the caret by one partial word at a time. As an example, this lets you move around inside both GetFileName and get_file_name.

Holding down the Meta key makes the up and down arrows move the caret to the beginning and end of the file, respectively, while the left and right arrows move the caret to the beginning and end of the current line, respectively. In addition, Meta-left-arrow is smart enough to move the caret to the beginning of the text on the line. Pressing it a second time moves the caret to the beginning of the line. (This is configurable in the preferences.)

Holding down the Shift key while using the arrow keys selects text. This works even in conjunction with the Meta, Control, and partial word modifier keys.

The backspace key on the main keyboard deletes the character to the left of the caret. The delete key on the keypad deletes the character to the right of the caret.

If automatic indentation is turned on, Shift-Return maintains the current indentation but ignores the line prefix.

Meta-comma activates the line number display so you can jump to a different line. Meta-Shift-comma activates the column number display so you can jump to a particular column on the current line. Pressing return takes you to the line or column that you have entered and returns you to the text. Pressing Shift-return in the line number display takes you to the line and activates the column number display.

External scripts

This feature allows you to paste the output of an arbitrary program into an editor window.

If you right-click on selected text (or Meta-right-click if you have "Allow Drag-and-Drop" disabled in the Preferences), the resulting context menu will include a menu of all the executable scripts in the directory that you selected in the File Types dialog. (Subfolders are also displayed so you can group scripts together if you have a lot of them.) The script that you select is run with the three arguments: path to the file, name of the file, line number of the start of the selection. The selected text is fed to the script via stdin (file descriptor 0) and is replaced by the script's output (file descriptor 1).

The "Run script" item on Edit menu provides a more general interface which allows you to specify the arguments to the script. In this case, the script must be on your execution path. You do not have to select any text in this case, but if you do, it will be fed to the script via stdin (file descriptor 0). The output of the script (file descriptor 1) will either be pasted in at the current caret location or will replace the selected text.

The following strings are replaced when they are used in the "Run script" dialog:

$f
full path and file name
$p
path
$n
file name
$l
line number

If a character is preceded by a backslash, the backslash is removed and any special meaning is ignored. Thus, use\$ to get a dollar character and \\ to get a backslash character.

Preferences

Word wrapping can be adjusted separately for each file type, so this option is in the File Types dialog.

The following options can be changed in the Text Editor Preferences dialog:

Font & Size
These menus let you change the font used in the Text Editor windows. The Size menu is only active if you choose a font from the second section of the Font menu. The sample text to the right of these menus is displayed using the font and size that you select.
Change color (6 buttons)
These buttons let you change the color of the text, the background, the insertion caret, the background of text that is selected, the frame that outlines the selected text when the window does not have focus, and the right margin indicator. The sample text above the buttons is displayed using the colors that you select. Note that you have to edit the context-sensitive highlighting colors separately to make them visible against the background color that you choose.
Emulator
Lets you emulate the behavior of anothe editor.
Spaces per tab
Adjusts the spacing of the tab stops.
Clean paragraph margins line width
Adjusts the width enforced by the "Clean paragraphs margins" item on the Edit menu.
Undo depth
Determines the number of actions that can by undone in each Text Editor window. Reducing the depth reduces the memory used by each Text Editor window.
Draw margin after column
If this is checked, a margin indicator will be drawn to the right of the specified column in every Text Editor window.
Enable Drag-And-Drop & context menu
If this is checked, you can drag text around inside each Text Editor window and also drag text from one Text Editor window to another. Also, right-clicking will open a menu of useful commands. (All these commands are in the menu bar, too, of course.) Holding down the Meta key toggles this setting while you work in a window.
Automatically indent new lines
If this is checked, the caret will be placed below the beginning of the text on the previous line after you press return. You can change this for individual windows using the Settings menu in the lower right corner.
Tab inserts spaces
This sets the default behavior for new windows. For existing files, Code Crusader auto-detects the appropriate setting. You can change the setting for individual windows using the Settings menu in the lower right corner of the Text Editor window.
Tab completes words and activates macros
If this is checked, pressing the tab key after typing a partial keyword will complete the keyword, and pressing the tab key after typing the name of a macro will activate it. If this is not checked, you can still use Control-Space to perform the same actions. If this is checked, you can still insert a tab character by holding down the Shift key.
Automatically copy text when it is selected
If this is checked, any text that you select will automatically be copied to the clipboard. This applies to input fields in dialogs as well as Text Editor windows.
Middle button pastes text
If this is checked, pressing the middle button on the mouse will paste the contents of the clipboard. This affects all text input areas, including Editor windows and dialog windows.
Balance grouping symbols while typing
If this is checked and you type ), }, or ] in a source window, the matching (, {, or [ will flash to show you where it is.
Scroll if outside view
If this is checked, the text will scroll if the balancing grouping symbol is not visible in the window. After flashing the symbol, the text will scroll back to where it was so you can keep typing.
Beep if symbol not balanced
If this is checked and you type an unbalanced ), }, or ], Code Crusader will beep.
Alphabetize Functions menu in source windows
If this is checked, the function names displayed in the Functions menu in source windows will be alphabetized. Otherwise, they will be displayed in the order defined in the file. If you hold down the Meta key and open the menu, the opposite of the current setting will be used.
Include namespace in Functions menu
If this is checked, the function names displayed in the Functions menu in source windows will include their namespaces. If you hold down the Shift key and open the menu, the opposite of the current setting will be used.
Use small font in Functions menu
If this is checked, the function names displayed in the Functions menu in source windows will be displayed in a smaller font so that more items fit on the screen.
Create backup file
Determines whether or not the original contents of the file will be copied to a backup file (e.g. foo.cc goes to foo.cc~) before the new contents are saved.
Only create backup file if it doesn't already exist
If this is checked, a backup file will only be created if one does not already exist. Otherwise, a backup file will be created every time after you open a file and save the first changes. This checkbox is disabled if "Create backup file" is not checked.
Open complement file on top of existing window
Normally, when one opens a source or header file, the preferences are used to place the window. When this is checked, however, the window is placed on top of its complement file, if this is already open.
Allocate space for *** in window title
The fvwm window manager decides the size of an iconified window when one iconifies it for the first time and does not change it after that, even if the window title changes. This can be annoying since Code Crusader prepends *** to the window title after you modify the text. If this option is checked, Code Crusader will prepend spaces to the initial window title so that the *** won't affect the window title's width. This option should not be used with fvwm95 because it allocates space in the task bar in a different way.
Modifier to move by partial word
This lets you choose which modifier key should activate "move by partial word." The Modifier Keys help section explains how to make a key map to Mod2 to Mod5. This is configurable because hardward constraints force some of Mod2 to Mod5 to be used for modifiers like NumLock, and this varies from system to system.
Meta-left-arrow moves to front of text
If this is checked, Meta-left-arrow will move the caret to the front of the text on the line. Using it again will move the caret to the front of the line. Otherwise, Meta-left-arrow will move the caret to the front of the line the first time it is used.
Home/End move to beginning/end of line
If this is checked, the Home/End keys move the caret to the beginning/end of the line instead of scrolling to the top/bottom of the text. To compensate, Control-Home/End scrolls to the top/bottom of the text. All the other shortcuts still work.
Caret follows when you scroll
If this is checked, the caret follows along when you scroll the text. You will also lose the selection when it scrolls out of view. If you use scrolltabs, then turning this option off makes it easier to return to the position where you are editing.

Emulators

vi

Newly opened windows start in Command mode. When in Input mode, Esc switches to Command mode. The following key bindings are implemented in Command mode:

Arrow keys
Move cursor
0 or ^
Go to beginning of line.
$
Go to end of line.
Return
Go to beginning of next line.
G
Go to end of file.
:0 Return
Go to beginning of file.
:# Return
Go to line.
:$ Return
Go to end of file.
Ctrl-U
Go up 1/2 page.
Ctrl-D
Go down 1/2 page.
Ctrl-B
Go up 1 page.
Ctrl-F
Go down 1 page.
i
Insert before cursor.
a
Insert after cursor.
I
Insert at beginning of line.
A
Insert at end of line.
o
Open new line below cursor.
O
Open new line above cursor.
x
Delete character at cursor.
X
Delete character before cursor.
yy or Y
Copy (yank) line.
y$
Copy (yank) from cursor to end of line.
dd
Delete line.
D or d$
Delete from cursor to end of line.
C
Delete from cursor to end of line and switch to insert mode.
/ or ?
Regular expression search.
n
Find next match.
u
Undo last change.
:w Return
Save file.
:w! Return
Save file.
:q Return
Close file. (Warns if unsaved.)
:q! Return
Close file. (Discards changes.)
:wq Return
Save and close file.

For any command that deletes, yanks, or pastes text, you can prepend a number to specify the number of items, e.g., 5x deletes five characters. You can also specify a named buffer, e.g., 5"ax deletes five characters and places them in the "a" buffer instead of the default buffer. "ap will then paste the contents of the "a" buffer.

Safety features

Code Crusader has several features to protect you from accidental crashes of both the X Server and Code Crusader itself:


Search & Replace

Note: When performing actions in the dialog window, the Text Editor window that will be affected is the one that was last clicked or typed in.

Searching for text

Enter the text for which to search in the "Search for" input area. The right "Find" button searches for the next match and selects it, while the left "Find" button searches for the previous match.

If "Ignore case" is checked, the search will not be case-sensitive. If "Wrap search" is checked, the search will wrap around if it hits the beginning or end of the text and will continue from the end or the beginning, respectively. If "Entire words only" is checked and the search text is also entire words (e.g. "hello" or "hi there", but not "this?"), the search will ignore matches that are part of other words. As an example, "and" will not match "sand".

If "Regex search (egrep)" is checked, the search text will be interpreted as a regular expression. The "Ref" button displays a short reference summary of regular expression syntax. If "Treat as single line" is checked, the regex will be allowed to match across multiple lines. Otherwise, each match will only be allowed to extend until it reaches a newline character.

Clicking on the down arrow next to the "Search for" input area displays a menu of the last 20 search patterns. Selecting one copies it to the input area.

The right "Find" button has the shortcuts Return and Meta-G. The left "Find" button has the shortcuts Shift-Return and Meta-Shift-G. The latter shortcuts are the same as in the Text Editor window.

Replacing text

Enter the text with which to replace the currently selected match in the "Replace with" input area. The "Replace" button replaces the selected text if it matches the current search text. The "Replace & Find" buttons do the same and then search for and select the next or previous match. If "Wrap search" is checked, the "Replace all" buttons search for all matches in the specified direction starting from the beginning or end of the text and replace each one. Otherwise, they search for all matches starting from the current caret position or selection and replace each one, stopping at the beginning or end of the text.

If "Regex replace" is checked, the replace pattern will be interpreted as a regular expression. Note that the shortcut for toggling this checkbox is Meta-Shift-X, because Meta-X is the shortcut for "Regex search."

If "Preserve case" is checked, the case of the replace text will be adjusted to match that of the matched search text, when possible. This is primarily useful when performing a case-insensitive search. The rules for when the case is adjusted are as follows:

  1. If the texts have the same length, the case of each character is adjusted separately. For example, matching "aBc" and replacing with "xyz" produces "xYz".
  2. Otherwise, the first letter's case is adjusted, and then the rest of the letters' cases are adjusted if all but the first letter in the matched text have the same case. For example, matching "aBC" and replacing with "wxyz" produces "wXYZ", while matching "AbC" produces "Wxyz".

Clicking on the down arrow next to the "Replace with" input area displays a menu of the last 20 replace patterns. Selecting one copies it to the input area.

The "Replace" button has the shortcut Meta-=. The right "Replace & Find" button has the shortcut Meta-L. The left "Replace & Find" button has the shortcut Meta-Shift-L. These are the same shortcuts as in the Text Editor window.

Searching for text in multiple files

If "Search directory" is checked, the right "Find" button will search each file that matches the wildcard filter in the specified directory. If you specify a relative path, it will be relative to the directory containing the active project, if any. If "Search all subdirectories" is checked, all subdirectories will also be searched, except those specified in the exception list. The exception list is a wildcard filter, just like the file name filter. (Symbolic links are not followed to avoid infinite loops.) If "Invert" is checked next to the wildcard filter, all files that do not match the given filter will be searched.

If "Search files" is checked, the right "Find" button will search each text file in the list.

These two "Search ..." checkboxes can be turned on at the same time. The checkboxes on the Options menu apply to both.

The output window will display each line that contains a match, underlining the text that matches. (If a file in the list is binary, it will not be searched.) The search is performed in the background, so you can continue to work. The Search Results window displays a progress indicator to show how much has been done.

As soon as each result is added to the Search window, you can open the file to see the match by Control-double-clicking on the file name or by using the Matches menu.

If you only want a list of the files that contain matches, turn on the "Only list file names" checkbox. If you want a list of the files that do not contain matches, turn on the "List files that do not match" checkbox.

Replacing text in multiple files

If "Search files" is checked, the right "Replace all" button will search each file in the list, open the ones with matches, and replace all the matches. This provides a second way to undo the changes, in addition to the "Cancel" button in the progress window, because you can simply close a file without saving it.

This option is only available if you are using the built-in editor.

Sharing search parameters between programs

Since many programs allow you to search through text, Code Crusader has been designed to allow the search parameters to be automatically shared with other programs via the XSearch protocol. The advantage of this is that you can use the "Enter search string" menu item in one program, the "Enter replace string" menu item in a second program, and then search and replace in a third program without ever having to use the clipboard to transfer any of the text. All the other options in the Search Text dialog are also shared, so you can configure a search in one program and then use it in any other program that supports the protocol.


Keyword completion

Keyword completion allows you to type the beginning of a word and then press Tab, Control-Space, or Control-Shift-Space to complete the word automatically. As an example, when writing C code, you could type cont and then Tab would complete it to give continue. (Macros provide the complementary functionality of automating specific, repetitive typing tasks. These are checked before keyword completion so that they can end with ordinary characters. Control-Shift-Space is provided as a trigger for keyword completion so macros can be ignored if necessary.)

You can turn off the special behavior of Tab in the Text Editor Preferences dialog. To insert a Tab character without triggering the completion mechanism, hold down the Shift key.

If the text matches more than one keyword, completion will fill in as many characters as possible. As an example, in C, r matches register, return, and reinterpret_cast, but they all start with re, so pressing Tab after r will add e. You can then type another character and press Tab again, e.g., typing t would complete the word to return.

If you press Tab and nothing is added, you can press Tab again to display a menu of all the matching completions. The first ten choices have the shortcuts 1, 2, ..., 9, 0, and the next twenty-size choices have the shortcuts a, b, ..., z, so you can avoid using the mouse most of the time. To close the menu without selecting anything, press Tab again. To insert a tab character via the menu, select the first item, which has the shortcut ` (single back quote).

The words that can be completed are the reserved keywords for the language (see below), any words that you enter into the bottom list in the corresponding dialog for context-sensitive highlighting, and all class names and methods in all open projects.

For HTML, only the names of special characters are included by default because it is a feature of HTML that there is no fixed list of tags, and the common tags are all very short. If you frequently use any long tags, simply enter them into the context-sensitive highlighting dialog. Usually, it is more convenient to create a macro for each tag because this can initialize the attributes at the same time.


Character Actions & Macros

Character Actions

Character Actions provide a way to automatically type a sequence of characters after you type a particular character. As an example, when writing C code, you could have the editor automatically type return after you type a semicolon.

Macros

Macros provide shortcuts for typing sequences of characters. A macro is activated by typing the shortcut and then pressing Tab or Control-Space. As an example, when writing C code, you could type #" and then Tab could activate the macro that converts this into #include "".

Keyword completion provides the complementary functionality of completing words regardless of how much you have already typed. This is checked after macros so that macros can end with ordinary characters.

You can turn off the special behavior of Tab in the Text Editor Preferences dialog. To insert a Tab character without triggering the macro, hold down the Shift key.

Defining actions and macros

You can create sets of actions and macros in the dialog obtained from the "Macros..." item on the Preferences menu in each Text Editor window.

In this dialog, the left columns contain the action or macro, while the right columns contain the keystrokes to perform. In the right column, all characters except for backslash (\) and dollar ($) translate directly to keystrokes. Backslash indicates a special character as follows:

\n    newline (return)
\t    tab
\b    backspace
\f    forward delete
\l    left arrow
\r    right arrow
\u    up arrow
\d    down arrow
\\    backslash
\$    dollar symbol

If any other character is preceded by a backslash, the backslash is simply removed.

Dollar is used to indicate a variable or a command to be executed:

$(...)
Execute command inside parentheses
The output of the command is treated as a sequence of keystrokes. This construct is nestable. The above special characters are not interpreted in the output of a command, so commands wishing to manipulate the cursor position must print the actual ASCII value of up/down/left/right.
$f
full path and file name
$p
path
$n
file name
$r
file name root
$s
file name suffix (including the period)
$l
line number of caret
$t
the line of text preceding the caret

To get a right parenthesis inside a command, use \). Similarly, to get a dollar symbol, use \$.

The characters typed by actions and macros do not trigger other actions or macros because it is very hard to avoid infinite loops and because it is much clearer if each keystroke script is self-contained.

Examples

For C/C++, the following actions can be useful:
; → \n
Starts a new line every time you type a semicolon.
{ → \n}\u\n
This creates the closing brace and then puts the caret on a blank line between the braces.

For C/C++, the following macros can be useful:

/* → __*/\l\l\l
Closes the comment (note the two spaces in front of */) and puts the caret inside so you can type the text.
#" → \binclude ""\l
Produces #include "" and puts the caret between the quotes so you can type the file name.
#< → \binclude <>\l
Produces #include <> and puts the caret between the brackets so you can type the file name.

For HTML, the following macros can be useful:

<a → _href="">\l\l
Fills in the anchor tag (note the space in front of href) and puts the caret between the quotes so you can type the URL.
<ul → >\n<li></li>\n</ul>\u\l
Creates a single item and the closing list tag and puts the caret inside the item tag so you can type the text.

For HTML, the following actions can be useful:

> → $(html-auto-close $t)
If > closes an opening tag, automatically inserts a closing tag. html-auto-close is included in the Code Crusader package.

For XML, the following actions can be useful:

> → $(xml-auto-close $t)
If > closes an opening tag, automatically inserts a closing tag. xml-auto-close is included in the Code Crusader package.

Context-sensitive Highlighting

Code Crusader provides context-sensitive highlighting for several languages.

The "... styles" items on the Preferences menu in the Text Editor windows allow you to turn highlighting on or off and to set the styles to be displayed.

The top list specifies the styles for the different types of text. As an example, the "Comment" item for C/C++ specifies how comments will be displayed in source and header files.

The bottom list specifies the styles for specific words that override the top list. As an example, if you created an item "#pragma" in the C/C++ window, then all #pragma directives would use this style instead of the style for "Preprocessor directive" in the top list. (The words in this list are also used for keyword completion.)

To change the style of an item, right-click on the item, and select from the menu that appears. To change the style of several items, select them and then right-click on any one of them. Note that fonts like 6x13 cannot be displayed in italic because there is no italic version of these fonts installed on most systems. Courier can be displayed in italic, however.

You cannot change the items in the top list, only their styles.

To add an item to the bottom list, click the "New" button. To remove items from the bottom list, select them and click the "Remove" button. To change the text of an item in the bottom list, double click on it.

Notes for Bourne/C shell

Notes for C/C++

Notes for HTML/PHP/XML

Addingn support for additional languages

The context-senstitive highlighting API is very simple, so it is easy to add support for other languages once a lexer is written. This cannot be linked in dynamically, however, because it does require minor changes to other parts of Code Crusader, such as the preferences file and the Preferences menus. If you are interested in adding support for another language, please submit a pull request via github.

Note that, in order to be compatible with Code Crusader, the code will have to be written in C++ and will have to use the JCore library.


Cleaning paragraph margins

Automatic indentation

When this feature is turned on in the Text Editor Preferences and you press Return, the Clean Paragraph Margin Rules discussed below are used to determine the current line's prefix. This prefix is then used to compute the prefix of the newly created line.

To copy only the whitespace, hold down the Shift key while pressing Return.

Cleaning paragraph margins

The "Clean paragraph margins" item on the Edit menu inserts and removes newlines in the paragraph that contains the caret so that no line exceeds the width set in the Text Editor Preferences. (default: 75)

A paragraph is defined as a sequence of non-empty lines that have the same prefix. A line is empty if it has no characters or only prefix characters.

If there is a selection, the item reads "Clean margins for selection" instead and performs the above operation on each paragraph touched by the selection.

The "Coerce paragraph margins" item defines a paragraph as a sequence of non-empty lines, even if the prefixes are different. This is useful if you want to force a change in the prefix, because you only have to change the prefix of the first line by hand.

Defining paragraph prefixes

The "Clean paragraph margins rules..." item on the Preferences menu in the Text Editor windows lets you define what a paragraph prefix is. You can define as many different sets of rules as you wish, and you can share them with others by using the "Load" and "Save" buttons. The File Type dialog lets you choose which set of rules to use for each file.

Each rule has three parts:

First line prefix
Regular expression that matches the prefix of the first line of the paragraph
Rest of lines prefix
Regular expression that matches the prefix of the rest of the lines of the paragraph
Replace prefix with
Replace expression from which the prefix of the rest of the lines of the paragraph is calculated

The rule for treating only whitespace as a prefix is built in, so you only have to specify rules for other patterns. You also do not need to use the up caret (^) anchor to specify that the match must occur at the beginning of the line because Code Crusader does this automatically.

A simple example is the single rule required for email:

  1. [[:space:]]*(>+[[:space:]]*)+
  2. [[:space:]]*(>+[[:space:]]*)+
  3. $0

The First and Rest patterns are the same because all lines begin with some mix of brackets (>) and spaces. The Replace pattern simply says to use the first line's prefix on all the following lines. "Clean paragraph margins" will therefore collect consecutive lines that begin with exactly the same pattern of brackets and spaces and rearrange the words to fit within the line width constraint set in the Text Editor Preferences. "Coerce paragraph margins" will first collect consecutive lines that begin with any pattern of brackets and spaces and will then change the prefix of each line to match the prefix of the first line before rearranging the words to fit within the line width constraint. Both will stop collecting if they find a line that contains nothing but brackets and spaces, because this is recognized as an empty line.

Here is an example:

Original text:

|---------------|
 > This sentence does not
 > fit on one
 >>line.

"Clean paragraph margins" result:

|---------------|
 > This sentence
 > does not fit
 > on one
 >>line.

"Coerce paragraph margins" result:

|---------------|
 > This sentence
 > does not fit
 > on one line.

A more complicated example is the two rules required for multiline C comments:

  1. ([[:space:]]*)/((\*+[[:space:]]*)+)
  2. [[:space:]]*(\*+/?[[:space:]]*)+
  3. $1 $2
  1. [[:space:]]*(\*+[[:space:]]*)+
  2. [[:space:]]*(\*+/?[[:space:]]*)+
  3. $0

The first rule specifies that the prefix of the first line is /* followed by more asterisks and spaces. Following lines start with spaces and asterisks, like this:

/* This C comment
 * spans two lines.
 */

The Rest pattern includes the possibility of a slash following the last asterisk in order to treat the line with */ as empty and force the collecting to stop.

The second rule specifies that one can also have a paragraph where all the prefixes are spaces and asterisks, like this:

/* This is the first line.
 *
 * This is a paragraph
 * within a C comment.
 */

Note the Rest pattern again includes the possibility of */, for the same reason.

Whenever you specify a rule where the first line's prefix is different from the rest, you must include a second rule which matches only the first rule's Rest pattern.

This not only allows sub-paragraphs, as in the C comment above, but it is also required by the algorithm that Code Crusader uses to find paragraph boundaries.


Viewing differences between files

The "Compare files" dialog lets you compare files in various ways:

Once the results are displayed, you can quickly find the differences by using the Differences menu. If you change one of the files or revisions, you can recalculate the differences via the "Redo diff" button.

Comparing two files on disk

The Normal tab lets you specify which two files to compare and the styles used to indicate the differences between them. Text that is only in the first file is displayed using the top Style menu, and text that is only in the second file is displayed using the bottom Style menu. Text that is common to both files is displayed using the "Shared text style" menu.

You can select files graphically by clicking the Choose buttons or by dropping files on the input fields via Drag-and-Drop.

A command line option is provided so you can alias "diff" to "jcc --diff" whenever you are running X. This normally requires two files. If you only specify one file, it assumes you want to compare file~ and file, unless the file name begins with #, in which case it assumes you want to compare it with the original. If you specify a file and a directory, it assumes that you want to use the file with the same name in the second directory.

Comparing two revisions of a file in a version control repository

The CVS, Subversion, and Git tabs let you specify the file and the revisions to be compared. The revisions work exactly the same as the corresponding command line interface. If the first revisions is "Current", the second revisions must be "Edited." If you select "Date" from either revision menu, CVS and Git accept any format, but Subversion requires YYYY-MM-DD.

If you enter a directory instead of a file, the raw output from the command line interface will be displayed in a window. Turning on the "Summary" option produces a summarized output. You can select a directory by holding down the Meta key and clicking on the Choose button.

Additional features

You can get the File Differences dialog via the "Compare files..." item on the Search menu in the Text Editor window and the Project menu in the Project and Symbol windows and any Class Tree window.

You can also compare files by using the "Compare selected files with backup" item on the Source menu in the Project window and the smart compare item on the File menu in the Text Editor window.


Miscellaneous notes

The Clipboard

By default, Code Crusader follows the Macintosh clipboard model. This means that text is not automatically copied when it is selected. Instead, it is only copied when you use the "Copy" item on the Edit menu or Meta-C. (Meta-C works in any input area, regardless of whether or not the window contains an Edit menu.) The main advantage of this model is that paste can then replace the selected text. If you prefer the X clipboard model, the Text Editor Preferences dialog lets you use this instead.

Useful Shortcuts

On PC's, Meta is normally bound to the Alt key on the keyboard. Your system's configuration may be different, however. You can use "xmodmap" to examine and change this configuration.

Drag-And-Drop can be cancelled by pressing the Escape key before releasing the mouse button.

Tab shifts focus to the next input area. Shift-Tab shifts focus to the previous input area.

To use a shortcut for a button or checkbox, hold down the Meta key and press the underlined character.

Scrolling

All scrollbars display increment/decrement arrow pairs if there is space. Coupled with the Shift key which makes the arrows scroll a half page at a time, this conveniently packages all the scrolling functions in one place.

Clicking the middle button in a scrollbar forces the thumb to jump to the place where you clicked.

The arrow keys scroll the tree, read-only text, and help by small steps the way the scrollbar arrows do. Meta-End and Meta-Page Up/Down scroll horizontally, just like End and Page Up/Down scroll vertically.

To save your current position so you can easily jump back to it later, hold down the Meta key and click the left mouse button on the scrollbar thumb. This creates a scrolltab. Clicking on this scrolltab scrolls to the saved location. You can place as many scrolltabs on each scrollbar as you wish.

Meta-left-click on scrollbar thumb
Place a scrolltab
Left-click on scrolltab
Jump to the saved position
Meta-left-click on scrolltab
Remove it
Meta-Shift-left-click on scrolltab
Remove all scrolltabs

These functions are also accessible via the menu that pops up when you right-click on the thumb or any scrolltab.

In the Project, Tree, and Text Editor windows, Control-1 through Control-9 scroll to the first through ninth vertical scrolltab, respectively.

The mouse wheel will scroll the widget that you point to:

No modifiers
Scroll five steps
Shift
Scroll one step
Control
Scroll one page
Meta
Scroll horizontally instead of vertically

The File Chooser

Tab completion in the Path input field is supported, but only when the caret is at the far right of the text. (This allows Tab to be used to switch to the next input area in all other situations.) You don't actually need tab completion, however, because typing in the file list table performs an incremental search, after which you can use the following keys:

Up-arrow
Moves up one item
Down-arrow
Moves down one item
Left-arrow
Meta-up-arrow
Goes up one directory (just like clicking on the Up button)
Right-arrow
Meta-down-arrow
Enters the selected directory
Return
Enters the selected directory or chooses the selected file

Note that Meta-up-arrow and Meta-down-arrow work even if the file list table does not have focus.

The next sub-section describes how to select multiple files in the Choose Files dialog.

Double clicking a file in the Save File dialog copies the name to the input field. This is useful if you want to replace a file or create a new file with a similar name.

The window is resizable, and always remembers its size and position.

Selecting more than one item in a list

If selecting more than one item at a time is possible in a particular list, you can do so with the following actions:

Left-click and drag
Selects files between where you click and where you release the button
Shift-left-click and drag
Right-click and drag
Selects files between where you last clicked and where you release the button
Shift-up/down-arrow
Selects files just like Shift-left-click
Control-left-click and drag
Selects/Deselects each file that you drag over

Editing items in a list or table

If you are editing an item in a list or a table, you can switch to a different item by using the following shortcuts:

Meta-up-arrow
Meta-8
Shift-Return
Moves up one row
Meta-down-arrow
Meta-2
Return
Moves down one row
Meta-left-arrow
Meta-4
Shift-Tab
Moves left one column
Meta-right-arrow
Meta-6
Tab
Moves right one column

The digits correspond to the appropriate positions on a numeric keypad.

How to avoid fiddling with windows

Code Crusader's paradigm is to display information in many separate windows instead of trying to cram everything into a single window. This allows you to easily place windows side by side so you can view more than one at a time and drag information from one to the other. It also allows you to place different windows on different virtual desktops. For those who prefer to work with all their windows arranged within a single window, refer to the section on Window Docks.

You can call up any particular window by using the Windows menu. To make it easier to navigate between windows without using the Windows menu, you should consider re-configuring your window manager/desktop to use the "point to focus" method and then adding a key shortcut that raises or lower the window that has focus. This allows you to simply point to a window with the cursor and then press a key to bring that window to the front.

In addition, Code Crusader has several features that minimize the amount of effort required to deal with window placement and focus:

Some window managers have an option that defeats Code Crusader's automatic window placement. To avoid this, you can do the following:

fvwm
Comment out "NoPPosition" from ~/.fvwmrc
fvwm2
Use "UsePPosition" instead of "NoPPosition" in ~/.fvwm2rc
sawfish
Select the Placement item for Sawfish in the Gnome control panel and change the Method to "None".
twm
Set "UsePPosition on" in ~/.twmrc

Window managers like KDE and Gnome that provide a taskbar listing all the currently open windows allow you to filter this list based on the window's title or WM_CLASS attribute. Code Crusader sets WM_CLASS as follows:

Project window
Code_Crusader_Project
Symbol List window
Code_Crusader_Symbol_List
Tree window
Code_Crusader_Tree
File List window
Code_Crusader_File_List
Text Editor window
Code_Crusader_Editor
Run Output window
Code_Crusader_Editor_Exec_Output
Compiler Output window
Code_Crusader_Editor_Compile_Output
Search Output window
Code_Crusader_Editor_Search_Output
Dock window
JX_Dock
Help window
JX_Help_Browser

The setting for the Compiler Output window allows you to either filter out all text windows with Code_Crusader_Editor* or filter out all other text windows with simply Code_Crusader_Editor. It is often convenient to display the Compiler Output window on the taskbar because the *** disappears when the compiler is finished.

Remapping modifier keys

You can choose which keys on your keyboard should map to each modifier by using xmodmap in your ~/.xinitrc file. As an example, if you have a PC keyboard with the new Windows key between Ctrl and Alt, you can change the left Windows key to produce the Mod4 modifier as follows:

xmodmap -e "clear mod4"
xmodmap -e "keycode 115 = Super_L"
xmodmap -e "add mod4    = Super_L"

To check which keys produce each modifier, use xmodmap -pm.

You can use xev to get the keycode for a particular key on your keyboard. Run it from a terminal window, move the cursor into the resulting window, press the key, and check the keycode value that is printed.