[Geany-devel] Deep editor customization....

Jimmy Paillet jimmy.paillet at xxxxx
Sat May 9 09:46:11 UTC 2009


2009/5/9 Enrico Tröger <enrico.troeger at uvena.de>

> 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().

yep i knew it was dodgy...ok i'll modify my stuff to get along these lines

> - 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().

ok...I was just using the scintilla model here...
forgetting the ! does not lead to an error, it just
don't anti-alias your font...
I'm not sure who, but someone might still want to have this control...

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

I didn't come across this yet...it's useful thanks


> Regards,
> Enrico
> --
> Get my GPG key from http://www.uvena.de/pub.asc
> _______________________________________________
> Geany-devel mailing list
> Geany-devel at uvena.de
> http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.geany.org/pipermail/devel/attachments/20090509/844e0469/attachment.html>

More information about the Devel mailing list