On Fri, 8 May 2009 20:59:15 +0200, Jimmy wrote:
Hey,
ok, just for fun, here's a patch to a basic functional version...(and the modified files in case patch is not working acording to plans...) it's tiny modifications to src/highlighting.c and src/highlighting.h :D
A few notes: - Don't use strcpy() with fixed sized strings like gchar custom_font[20] this can easily lead to memory corruptions and so crashes. It's easier and safer (while being a little less performant) to use dynamically allocated strings on the heap, e.g. with g_strdup(), so gchar custom_font[20]; strcpy(style->custom_font, list[4]); gets gchar *custom_font; custom_font = g_strdup(list[4]); And don't forget to g_free() these strings afterwards in highlighting_free_styles().
- if (condition) code(); looks nicer than if (condition) code(); but this is just cosmetic.
- I think we should add the "!" to request Pango fonts in the code, I don't think users want to use GDK fonts and mixing both is probably not possible at all and even if, it's not desirable. Furthermore, having the "!" in the filetype definition files seems error-prone because it can be easily forgotten. This is why I suggest to specify only fontnames in the filetype definition files and add the "!" directly when reading the names in get_keyfile_int().
- strlen(style_ptr->custom_font) > 0 can be easier written as NZV(style_ptr->custom_font) which is a little more performant and easier to read (the NZV() macro is defined in src/utils.h).
Regards, Enrico