[Geany] Adding Syntax Highlighting for New FIletype Problem

Jason Oster parasytic at xxxxx
Fri Sep 19 13:32:08 UTC 2008


Scintilla needs to find the SCLEX_R lexer. Most of the default lexers  
are removed for Geany (scintilla/Lex*.cpp files) You should be able to  
download a copy of Scintilla 1.76 and copy the proper lexer file into  
Geany's scintilla dir. That should be the only thing left to do, if I  
recall...

Jay

On Sep 19, 2008, at 2:46 AM, Andrew Rowland wrote:

> All,
>
> I am attempting to add filetype and syntax highlighting support for R
> scripts.  I am following the steps outlined in HACKING.  I've added
> GEANY_FILETYPES_R to filetypes.h, initialized GEANY_FILETYPES_R in
> init_builtin_filetypes(), and updated data/filetype_extensions.conf.
> After rebuilding Geany, R scripts show up in the Filetypes menu under
> scripting languages and Geany recognizes *.R and *.r files as R  
> scripts.
> So, the first step was successful.
>
> On to the syntax highlighting.  I shamelessly stole LexR.cxx from
> scintilla and I've created data/filetypes.r.  I then wrote the
> styleset_r_init() and styleset_r() functions, added
> init_styleset_case(GEANY_FILETYPES_R, r) to  
> highlighting_init_styles(),
> and added styleset_case(GEANY_FILETYPES_R, r)
> to highlighting_set_styles().
>
> Unfortunately, the only style that is applied to R scripts is the
> default style.  If I change the hex color codes in highlighting.c or  
> in
> data/filetypes.r, the new colors will be used.  However, none of the
> other styles are being used.
>
> Below are my init_styleset_case() and styleset_case() functions.  I'm
> sure it's something I've done wrong, but I can't see the problem.  A
> pointer in the right direction would be appreciated.
>
> TIA
>
> Andrew
>
> static void styleset_r_init(gint ft_id, GKeyFile *config, GKeyFile
> *config_home)
> {
> 	new_style_array(GEANY_FILETYPES_R, 12);
>
> 	get_keyfile_hex(config, config_home, "styling", "default",  
> "0x000000",
> "0xffffff", "false", &style_sets[GEANY_FILETYPES_R].styling[0]);
> 	get_keyfile_hex(config, config_home, "styling", "comment",  
> "0x000000",
> "0xffffff", "false", &style_sets[GEANY_FILETYPES_R].styling[1]);
> 	get_keyfile_hex(config, config_home, "styling", "kword", "0xF70808",
> "0xffffff", "false", &style_sets[GEANY_FILETYPES_R].styling[2]);
> 	get_keyfile_hex(config, config_home, "styling", "operator",  
> "0x000fff",
> "0xffffff", "false", &style_sets[GEANY_FILETYPES_R].styling[3]);
>    get_keyfile_hex(config, config_home, "styling", "basekword",
> "0x000fff", "0xffffff", "true",
> &style_sets[GEANY_FILETYPES_R].styling[4]);
>    get_keyfile_hex(config, config_home, "styling", "otherkword",
> "0x119911", "0xffffff", "true",
> &style_sets[GEANY_FILETYPES_R].styling[5]);
>    get_keyfile_hex(config, config_home, "styling", "number",
> "0x000fff", "0xffffff", "true",
> &style_sets[GEANY_FILETYPES_R].styling[6]);
>    get_keyfile_hex(config, config_home, "styling", "string",
> "0x119911", "0xffffff", "true",
> &style_sets[GEANY_FILETYPES_R].styling[7]);
>    get_keyfile_hex(config, config_home, "styling", "string2",
> "0x119911", "0xffffff", "true",
> &style_sets[GEANY_FILETYPES_R].styling[8]);
>    get_keyfile_hex(config, config_home, "styling", "identifier",
> "0x119911", "0xffffff", "true",
> &style_sets[GEANY_FILETYPES_R].styling[9]);
>    get_keyfile_hex(config, config_home, "styling", "infix",  
> "0x119911",
> "0xffffff", "true", &style_sets[GEANY_FILETYPES_R].styling[10]);
> 	get_keyfile_hex(config, config_home, "styling", "infixeol",  
> "0x119911",
> "0xffffff", "true", &style_sets[GEANY_FILETYPES_R].styling[11]);
> 	
> 	style_sets[GEANY_FILETYPES_R].keywords = g_new(gchar*, 2);
> 	get_keyfile_keywords(config, config_home, "keywords", "primary",
> GEANY_FILETYPES_R, 0, "if source array matrix diag solve for");
> 	style_sets[GEANY_FILETYPES_R].keywords[1] = NULL;
>
> 	get_keyfile_wordchars(config, config_home,
> 		&style_sets[GEANY_FILETYPES_R].wordchars);
> }
>
>
> static void styleset_r(ScintillaObject *sci)
> {
> 	const filetype_id ft_id = GEANY_FILETYPES_R;
>
> 	styleset_common(sci, 5, ft_id);
>
> 	apply_filetype_properties(sci, SCLEX_R, ft_id);
>
> 	SSM(sci, SCI_SETKEYWORDS, 0, (sptr_t)
> style_sets[GEANY_FILETYPES_R].keywords[0]);
>
> 	set_sci_style(sci, STYLE_DEFAULT, GEANY_FILETYPES_R, 0);
> 	set_sci_style(sci, SCE_R_DEFAULT, GEANY_FILETYPES_R, 0);
> 	set_sci_style(sci, SCE_R_COMMENT, GEANY_FILETYPES_R, 1);
> 	set_sci_style(sci, SCE_R_KWORD, GEANY_FILETYPES_R, 2);
> 	set_sci_style(sci, SCE_R_OPERATOR, GEANY_FILETYPES_R, 3);
> 	set_sci_style(sci, SCE_R_BASEKWORD, GEANY_FILETYPES_R, 4);
> 	set_sci_style(sci, SCE_R_OTHERKWORD, GEANY_FILETYPES_R, 5);
> 	set_sci_style(sci, SCE_R_NUMBER, GEANY_FILETYPES_R, 6);
> 	set_sci_style(sci, SCE_R_STRING, GEANY_FILETYPES_R, 7);
> 	set_sci_style(sci, SCE_R_STRING2, GEANY_FILETYPES_R, 8);
> 	set_sci_style(sci, SCE_R_IDENTIFIER, GEANY_FILETYPES_R, 9);
> 	set_sci_style(sci, SCE_R_INFIX, GEANY_FILETYPES_R, 10);
> 	set_sci_style(sci, SCE_R_INFIXEOL, GEANY_FILETYPES_R, 11);
> }
>
> _______________________________________________
> Geany mailing list
> Geany at uvena.de
> http://lists.uvena.de/cgi-bin/mailman/listinfo/geany




More information about the Users mailing list