If the language you need to edit in the editor widget is known at compile time, there is no need to load it dynamically. You can simply link it with the application. To create a scanner from a statically linked scanner you use the function gtk_editor_static_scanner. It takes as arguments the methods that implements the scanner and return a scanner object. The methods can then be linked in from the scanner object file.
If, for example, you want a C editor, and nothing more, you can add the prototypes in Example 2-5 and create the scanner as shown in Example 2-6
Example 2-5. Prototypes for a Statically Linked Scanner
/* these symbols we get from the scanner */ extern const char *get_name (void); extern const char **get_token_names (void); extern const char **get_block_names (void); extern int get_token_no (const char *); extern int get_block_no (const char *); extern void token_func (void (*func)(int id, int precedence, int length, int pos, int block_id, int nesting, int block_type)); extern void char_func (int (*func)()); extern int get_state (void); extern void set_state (int state); extern int lex (); |