[Geany-devel] Geany Plugin with Libxml

Philipp Gildein philipp at xxxxx
Sun Aug 9 19:28:33 UTC 2009


Hi,

Am Sonntag, den 09.08.2009, 18:37 +0200 schrieb Cédric Tabin:
> Hi Enrico,
> 
> Thanks for your advices. Since I don't develop pretty much in C, I
> don't know the geany-standards very well. I'll correct that :-) For
> formatting the current selection there are two technical problems I
> see :
> - The selected text must be a valid XML (from start node to its
> closing tag).

This could be a problem with libxml. Most "big" xml parsing libraries
are also checking for valid xml code. But for your purposes a smaller,
simpler xml parser with less checking could do the trick, too. If you
can't find one, there is always the possiblity of writing one yourself
(which isn't very hard, i've done it myself one time). 

> - How do I get the depth of the selected node ?

Should also be easily possible with a custom implementation :)

Regards 
Philipp Gildein

> Currently, my parser just take a char* and formats it, so I can send
> it the selection (since it is a XML) and it will format it. I didn't
> have care of just formatting one part, but maybe I'll try in a futur
> version :-)
> 
> I just sent you a request to join the geany project on sourceforge.
> 
> Best regards,
> Cedric
> 
> 2009/8/9 Enrico Tröger <enrico.troeger at uvena.de>
>         On Sat, 8 Aug 2009 14:00:52 +0200, Cédric wrote:
>         
>         Heyho,
>         
>         about compiling and your friend using Ubuntu:
>         sharing binary files (.so) between different systems and
>         especially
>         between different distributions usually don't work (we are not
>         on
>         Windows...) and it's not designed to work. Instead, compile
>         the code
>         from source on the target platform, that should do the trick.
>         If your
>         friend still don't get the plugin listed in the plugin manager
>         dialog,
>         tell him to check Help->Debug Messages for details. There
>         should be a
>         message indicating why it could not be loaded.
>         
>         
>         >Okay, here is an update => in case of invalid char, it won't
>         shut down
>         
>         
>         Just for clarity, "shut down" seems the wrong term here. You
>         are surely
>         talking about a crash. A shut down is something normal which
>         is
>         expected but you are talking about a crash which happened
>         because of
>         wrong code, I guess.
>         
>         
>         >geany. I also correct some other bugs, but DOCTYPE is
>         currently not
>         >supported.
>         >I'll try to add the options with what you sent me !
>         
>         
>         A few unsorted notes after having a short look at the plugin:
>         
>         - it's a great idea. I personally probably won't use it much
>         as I don't
>         use XML much but in general it's getting probably pretty
>         useful for
>         many users.
>         
>         - If you would use g_warning() and/or other g_foo() log
>         functions, your
>         messages would also be available in Help->Debug Messages which
>         makes
>         searching for information/warnings/errors easier as most users
>         don't
>         run Geany from a console.
>         
>         - If the menu item is activated, it always works on the whole
>         document.
>         I think it's more intuitive and even more usable if it would
>         work only
>         on the current selection if there is any and the whole
>         document if
>         there is no selection. This is how most text modifiying
>         functions work
>         in Geany (and other applications as well). Some very basic
>         example code
>         could look like this:
>         gchar *buffer;
>         gint length;
>         if (sci_has_selection(sco))
>         {
>                length = sci_get_selected_text_length(sco);
>                buffer = g_malloc0(len + 1);
>                if (buffer == NULL) { exit(-1); } //malloc error
>                sci_get_selected_text(sco, buffer);
>         }
>         else
>         {
>                length = sci_get_length(sco);
>                buffer = g_malloc0(length + 1);
>                if (buffer == NULL) { exit(-1); } //malloc error
>                //retrieves the text
>                sci_get_text(sco, length, buffer);
>         }
>         
>         
>         And remember I suggested to join the geany-plugins project [1]
>         so your
>         code would be in the SVN repository and will be released with
>         the next
>         geany-plugins combined release.
>         
>         
>         [1]
>         http://lists.uvena.de/pipermail/geany-devel/2009-June/000747.html
>         
>         
>         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
>         
> 
> _______________________________________________
> Geany-devel mailing list
> Geany-devel at uvena.de
> http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel




More information about the Devel mailing list