CodeCommander

-

Customization Information

CodeCommander is one of the most customizable applications in the entire GNOME collection. The reason for this is it's use of Python or Guile as a scripting language. This file is here to help you customize CodeCommander to fit your specific needs.




Language Definition Information

A line may be commented out by placing a '#' in the first column
CodeCommander uses the GNU regex library.

[Section 1: General Settings]

<settings>               // beginning tag
language=C/C++                 // Description of the language
compiler=gcc -g %2 -o %3 2>&1  // the command to use for compiling (by default)
debugger=xterm -e gdb %3       // command for debugging
execution=./%3                 // command for execution
auto_indent=1                  // is auto indenting on?
indent_chars={                 // list of chars that should envoke an auto-tab (after pressing enter)
use_spaces=0                   // should spaces be used instead of tabs?
tab_stop=4                     // how wide (in spaces) are tabs?
</settings>              // end tag

Constants for compiler, debugger and execution:
%term% = the default terminal command, as set in the general preferences.
%make% = the default make command, as set in the general preferences.
%1 = Path to the current file, as set in the directory entry, or if the directory entry is empty, it will be the path to the current file.
%2 = The name of the file without path, but with extension. (if it has one)
%3 = The name of the file without path or extension.

[Section 2: Supported Extensions]


<extensions>
 <item name="c source file" ext="c">
 <item name="include file" ext="h">
 <item name="c++ source file" ext="cpp">
</extensions>
This is simply a list of supported extensions.

[Section 3: Highlighting between 2 regex's]

<syntax>
 <item name="string" start="\"" end="\"" color="string" class="d">
</syntax>
or...
<python>
import cc
cc.add_syntax_entry("string", "\"", "\(\"\|\n\)", "string", "d")
</python>
or...
<guile>
(add-syntax-entry "string" "\"" "\\(\"\\|\\n\\)" "string" "d")
</guile>

Note: cc is the python module for CodeCommander.
Arg1: the name of the highlight class.
Arg2: the regex of the start of the highlight.
Arg3: the regex of the end of the highlight.
Arg4: the color class (see section 6)
Arg5: the font class (see section 7)

[Section 4: Highlighting words and characters]

<pattern>
 <item name="labels" words="^[a-zA-Z_]*\:" color="function" class="b">
</pattern>
or...
<python>
import cc
cc.add_pattern_entry("labels", "^[a-zA-Z_]*\:", "function", "b")
</python>
or...
<guile>
(add-pattern-entry "labels" "^[a-zA-Z_]*\\:" "function" "b")
</guile>

Note: cc is the python module for CodeCommander.
Arg1: the name of the highlight class.
Arg2: the regex of the 'words' to highlight.
Arg3: the color class (see section 6)
Arg4: the font class (see section 7)

Note: notice that guile often times uses 2 '\' characters instead of 1.
This is due to it's string parsing routines. Just deal with it :-)

[Section 5: Highlighting words and characters between 2 specified regex's]

<embedded>
 <item name="keywords1" start="<" words="\b\(bgcolor\|size\|target\|href\)\b" end=">" color="data_type" class="i">
</embedded>
<python>
import cc
cc.add_embedded_entry("keywords1", "<", r'\b\(bgcolor\|size\|target\|href\)\b', ">", "data_type", "i")
</python>
or...
<guile>
(add-embedded-entry("keywords1" "<" "\b\(bgcolor\|size\|target\|href\)\b" ">" "data_type" "i")
</guile>

Note: cc is the python module for CodeCommander.
Arg1: the name of the highlight class.
Arg2: the regex of the start of the area to check.
Arg3: the regex of the 'words' to highlight.
Arg4: the regex of the end of the area to check.
Arg5: the color class (see section 6)
Arg6: the font class (see section 7)
Note: notice that r' ' is used in the Python section. This is because Python will evaluate
\b as a character with a standard string.


[Section 6: Color classes]

When possible, it is a good practice to use the color classes rather than 
the explicit colors in case the user wants to change the background to something 
incompatible with a particular text color.

The last one, 'default' is special because is will change whenever the default text color changes. This is for those of you who like to make your keywords bold, but the same color as normal text.

See the Python and Guile Binding documentation for more information on other code
that can be executed in language definitions.


[Section 7: Font classes]

You can mix and match these just about however you want (within logical reason...'d' and 'i' will still get you the default font). However, it is best to only use them with explicit colors (red, blue, etc) and let the user (which may or may not be you) choose the proper font style int he Highlight Colors dialog within CodeCommander.


Python Binding Information

[ Python Module : cc ]


[1.  Introduction]

This file documenents the macro language for CodeCommander. We use PYTHON
as the macro language.

You can execute a single macro command by typing it in the 'Command' entry 
of the CodeCommander toolbar. You can run macros from the Command entry,
or from the 'Scripts' menu.

When CodeCommander starts, it executes the macros from the 
'./CodeCommander/autoexec.py' file in the user's home directory.
This is useful to customize CodeCommander menu entries.


[2.  Avaliable macro commands]

int get_file_number()
int change(int file_no)
int get_files()
int get_file_length(int file_no)
int get_file_tab_width(int file_no)
char *get_full_filename(int file_no)
char *get_filename(int file_no)
char *get_path(int file_no)
char *get_file(int file_no)
int has_selection()
int selection_start()
int selection_end()
void move(int relative_movement)
void move_to(int index)
int current_position(void)
int  buffer_size(void)
void insert_in(int file_no, int pos, char* text)
void insert(char* text)
void move_to_line (int index)
void move_lines (int relative_movement)
int current_line()
int line_start()
int line_end()
int freeze()
int thaw()
int line_by_pos(int pos)
void move_to_col(int index)
char* get_text(int begin,int end)
char get_current_char()
char get_next_char()
void delete_text(int start, int end)
void delete_text_in(int file_no, int start, int end)
void forward_delete (int n)
void backward_delete (int index)
void undo()
void undo_last(int file_no)
void redo()
void redo_last(int file_no)
void cut()
void cut_text(int file_no)
void copy()
void copy_text(int file_no)
void paste()
void paste_text(int file_no)
void clear()
void clear_text(int file_no)
void clear_entry()
void select_area(int from, int to)
void select_text(int file_no, int from, int to)
void select_current()
void select_all()
void select_all_text(int file_no)
void highlight_syntax(int file_no)
void new_window()
void new_file(char *filename)
void open_file(char *filename)
void close_file(int file_no)
void save_all_files()
void close_all_files()
int find(char *text)
int find_in(int file_no, char *text)
int find_regex(char *text)
int find_regex_in(int file_no, char *text)
int replace(char *search_text, char *replacer)
int replace_in(int file_no, char *search_text, char *replacer)
int replace_all(char *search_text, char *replacer)
int replace_all_in(int file_no, char *search_text, char *replacer)


[2.1 CodeCommander menu customizations]

void add_item_to_scripts_menu(char * label, int position, PyObject *function)

int add_sub_to_scripts_menu(char *label, int position)

void add_item_to_insert_menu(char * label, int position, PyObject *function)

int add_sub_to_insert_menu(char *label, int position)

void add_item_to_popup_menu(char * label, int position, PyObject *function)

int add_sub_to_popup_menu(char *label, int position)

void add_item_to_build_menu(char * label, int position, PyObject *function)

int add_sub_to_build_menu(char *label, int position)

The return value of the add_sub functions is a pointer index to the sub menu. You can then pass this number as the second argument of the add_item functions to add an item to a particular submenu.

[2.2 Items available *only* in language definitions]

void add_syntax_entry(char *name, char *start, char *end, char *color, char *cclass)

void add_pattern_entry(char *name, char *words, char *color, char *cclass)

void add_embedded_entry(char *name, char *start, char *words, char *end, char *color, char *cclass)


Guild Binding Information

[1.  Introduction]

This file documenents the macro language for CodeCommander. We use Guile
as the macro language.

You can execute a single macro command by typing it in the 'Command' entry 
of the CodeCommander toolbar. You can run macros from the Command entry,
or from the 'Scripts' menu.

When CodeCommander starts, it executes the macros from the 
'./CodeCommander/autoexec.scm' file in the user's home directory.
This is useful to customize CodeCommander menu entries.


[2.  Avaliable macro commands]

int get-file-number()
int change(int file-no)
int get-files()
int get-file-length(int file-no)
int get-file-tab-width(int file-no)
char *get-full-filename(int file-no)
char *get-filename(int file-no)
char *get-path(int file-no)
char *get-file(int file-no)
int has-selection()
int selection-start()
int selection-end()
void move(int relative-movement)
void move-to(int index)
int current-position(void)
int  buffer-size(void)
void insert-in(int file-no, int pos, char* text)
void insert(char* text)
void move-to-line (int index)
void move-lines (int relative-movement)
int current-line()
int line-start()
int line-end()
int freeze()
int thaw()
int line-by-pos(int pos)
void move-to-col(int index)
char* get-text(int begin,int end)
char get-current-char()
char get-next-char()
void delete-text(int start, int end)
void delete-text-in(int file-no, int start, int end)
void forward-delete (int n)
void backward-delete (int index)
void undo()
void undo-last(int file-no)
void redo()
void redo-last(int file-no)
void cut()
void cut-text(int file-no)
void copy()
void copy-text(int file-no)
void paste()
void paste-text(int file-no)
void clear()
void clear-text(int file-no)
void clear-entry()
void select-area(int from, int to)
void select-text(int file-no, int from, int to)
void select-current()
void select-all()
void select-all-text(int file-no)
void highlight-syntax(int file-no)
void new-window()
void new-file(char *filename)
void open-file(char *filename)
void close-file(int file-no)
void save-all-files()
void close-all-files()
int find(char *text)
int find-in(int file-no, char *text)
int find-regex(char *text)
int find-regex-in(int file-no, char *text)
int replace(char *search-text, char *replacer)
int replace-in(int file-no, char *search-text, char *replacer)
int replace-all(char *search-text, char *replacer)
int replace-all-in(int file-no, char *search-text, char *replacer)


[2.1 CodeCommander menu customizations]

void add-item-to-scripts-menu(char *label, int position, PyObject *function)

int add-sub-to-scripts-menu(char *label, int position)

void add-item-to-insert-menu(char *label, int position, PyObject *function)

int add-sub-to-insert-menu(char *label, int position)

void add-item-to-popup-menu(char *label, int position, PyObject *function)

int add-sub-to-popup-menu(char *label, int position)

void add-item-to-build-menu(char *label, int position, PyObject *function)

int add-sub-to-build-menu(char *label, int position)

The return value of the add-sub functions is a pointer index to the sub menu. You can then pass this number as the second argument of the add-item functions to add an item to a particular submenu.

[2.2 Items available *only* in language definitions]

void add-syntax-entry(char *name, char *start, char *end, char *color, char *cclass)

void add-pattern-entry(char *name, char *words, char *color, char *cclass)

void add-embedded-entry(char *name, char *start, char *words, char *end, char *color, char *cclass)



CodeCommander is Copyright 1999-2000 by Chris Phelps