Glimmer Customization Information

# Glimmer

-

### Customization Information

Glimmer 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 Glimmer to fit your specific needs.

- Language Definitions
- Color Classes
- Font Classes
- Python Language Bindings

### Language Definition Information

    A line may be commented out by placing a '#' in the first column
    Glimmer 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?
    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 glimmer
    glimmer.add_syntax_entry("string", "\"", "\(\"\|\n\)", "string", "d")
    </python>
    or...
    <guile>
    (glimmer-add-syntax-entry "string" "\"" "\\(\"\\|\\n\\)" "string" "d")
    </guile>

    Note: glimmer is the python module for Glimmer.
    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 Glimmer.
    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 Glimmer.
    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]

- string
- char
- char_string
- keyword
- comment
- preprocessor
- data_type
- function
- macro
- variable
- symbol
- operator
- punctuation
- decimal
- hexidecimal
- octal
- white
- black
- gray
- blue
- dark_blue
- red
- dark_red
- green
- dark_green
- cyan
- magenta
- yellow
- orange
- default (this changes with the default color)

    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]

- Default = 'd'
- Italic = 'i'
- Bold = 'b'
- Bold+Italic = 'bi'
- Strikeout = 's'
- Underline = 'u'

    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 Glimmer.

### Python Binding Information

    [ Python Module : glimmer ]

    [1.  Introduction]

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

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

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

    [2.  Macro commands]

    int get_file_number()
    int change(int file_no)
    int get_files()
    char *get_default_term_command();
    char *get_default_make_command();
    bool get_tab_stops()
    int get_file_length(int file_no)
    int get_file_tab_width(int file_no)
    int get_file_use_spaces(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)
    char *get_file_compile_string(int file_no);
    char *get_file_debug_string(int file_no);
    char *get_file_execute_string(int file_no);
    void set_file_done_compiling(int file_no);
    void set_file_done_debugging(int file_no);
    void set_file_done_executing(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 PyGtk specific fuctions]

    // Add a widget to the dock of the main window
    void add_dock_item(GtkWidget *w, char *name, int band_number, int placement, int band_position, int offset)

    // Get a pointer to the main window
    GtkObject *get_gnome_app()

    // Get a pointer to GdsFile::script_box
    GtkObject *get_file_box(int file_no)

    // Get a pointer to GdsFile::text
    GtkObject *get_text_widget(int file_no)

    [2.2 Scripts/Insert/Build/Popup Menus]

    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)

    Note: 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.3 Custom Toolbar]

    void add_custom_toolbar_entry(char *label, int position, char *pixmap, int type, void *callback)

    int append_custom_toolbar_page(char *label)

    Note: The return value of append_custom is an index that you can pass as arg2 of add_custom_toolbar_entry. Else, use -1.

    [2.4 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)

    // Register a callback for an event
    void register_signal_hook(char *signal, void *function)

    Signals valid in language definitions:
      table-add
      table-remove
      table-destroy
      focus-in
      focus-out
      enter-pressed
      tab-pressed
      compile
      stop-compile
      debug
      stop-debug
      execute
      stop-execute

    Signals valid anywhere:
      open-file
      revert-file
      save-file
      save-as-file
      close-file
      change-file
      move-left
      move-right

Glimmer is Copyright 1999-2000 by Chris Phelps