Hello,
I try to code a small plugin that uses libxml2 to parse some data. I searched a lot, but I don't understand how I can tell Geany that I want to use that lib...
To compile my file, I use the following command lines :
compilation gcc -o "output.o" -Wall -c -fpic "plugin.c" `pkg-config --cflags geany` `pkg-config --cflags libxml-2.0`
for the shared library gcc -shared -o "output.so" "output.o"
Thanks and best regards ! Cedric
On Tue, 23 Jun 2009 19:53:27 +0200 Cédric Tabin tabin.cedric@gmail.com wrote:
I try to code a small plugin that uses libxml2 to parse some data. I searched a lot, but I don't understand how I can tell Geany that I want to use that lib...
I'm not sure what you want to do here. Can you please go a bit more in detail?
Thanks, Frank
Hi,
I just want to use the functions of the libxml2 into my Geany Plugin. Until now, it compiles well, but when I put it into my .config/geany/plugins, the module fails its initialization and I can't see it into the plugin list...
Regards, Cedric
On Tue, Jun 23, 2009 at 8:26 PM, Frank Lanitz frank@frank.uvena.de wrote:
On Tue, 23 Jun 2009 19:53:27 +0200 Cédric Tabin tabin.cedric@gmail.com wrote:
I try to code a small plugin that uses libxml2 to parse some data. I searched a lot, but I don't understand how I can tell Geany that I want to use that lib...
I'm not sure what you want to do here. Can you please go a bit more in detail?
Thanks, Frank -- http://frank.uvena.de/en/
Geany-devel mailing list Geany-devel@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
On Wednesday 24,June,2009 01:53 AM, � wrote:
Hello,
I try to code a small plugin that uses libxml2 to parse some data. I searched a lot, but I don't understand how I can tell Geany that I want to use that lib...
To compile my file, I use the following command lines :
compilation gcc -o "output.o" -Wall -c -fpic "plugin.c" `pkg-config --cflags geany` `pkg-config --cflags libxml-2.0`
for the shared library gcc -shared -o "output.so" "output.o"
I think you'll need to link it as well, so try this: gcc -shared -o output.so output.o `pkg-config --libs geany libxml-2.0`
Hello,
Thanks for the advice :) I just try and it works perfectly !!!
Regards Cedric
On Tue, Jun 23, 2009 at 9:00 PM, Chow Loong Jin hyperair@gmail.com wrote:
On Wednesday 24,June,2009 01:53 AM, � wrote:
Hello,
I try to code a small plugin that uses libxml2 to parse some data. I searched a lot, but I don't understand how I can tell Geany that I want
to
use that lib...
To compile my file, I use the following command lines :
compilation gcc -o "output.o" -Wall -c -fpic "plugin.c" `pkg-config --cflags geany` `pkg-config --cflags libxml-2.0`
for the shared library gcc -shared -o "output.so" "output.o"
I think you'll need to link it as well, so try this: gcc -shared -o output.so output.o `pkg-config --libs geany libxml-2.0`
-- Regards, Chow Loong Jin
Geany-devel mailing list Geany-devel@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
On Wednesday 24,June,2009 03:05 AM, Cédric Tabin tabin.cedric@gmail.com wrote:
Hello,
Thanks for the advice :) I just try and it works perfectly !!!
Regards Cedric
Good to hear. You should consider using a build system to compile your plugins though. And perhaps release your code so that others may benefit from it too. =)
On Wed, 24 Jun 2009 03:16:04 +0800, Chow wrote:
On Wednesday 24,June,2009 03:05 AM, Cédric Tabin tabin.cedric@gmail.com wrote:
Hello,
Thanks for the advice :) I just try and it works perfectly !!!
Regards Cedric
Good to hear. You should consider using a build system to compile your plugins though. And perhaps release your code so that others may benefit from it too. =)
+1.
If you want, you can join the geany-plugins project which means you get write access to the Subversion repository and if you like, make your plugin part of the common geany-plugins release (which gives your plugin translations and a build system for free :D).
Just tell us if you like.
Regards, Enrico
On Wed, 24 Jun 2009 03:16:04 +0800 Chow Loong Jin hyperair@gmail.com wrote:
On Wednesday 24,June,2009 03:05 AM, Cédric Tabin tabin.cedric@gmail.com wrote:
Hello,
Thanks for the advice :) I just try and it works perfectly !!!
Good to hear. You should consider using a build system to compile your plugins though. And perhaps release your code so that others may benefit from it too. =)
I second this. Maybe we can include it to common geany-plugins distribution in case of its useful for other users also.
Cheers, Frank
Hello geany-guys :)
I come back to you with my (very) small plugin. It allows you to (very) quickly format an XML. The following :
<?xml version="1.0" encoding="utf-8"?><root id="543"><!-- This is a simple XML sample --><geany user="aname"><var id="name">Cedric</var><var id="country">Switzerland</var></geany><comments><![CDATA[Our cows are very funny => Drink our milk :-)]]></comments></root>
becomes in one click something like that :
<?xml version="1.0" encoding="utf-8"?> <root id="543"> <!-- This is a simple XML sample --> <geany user="aname"> <var id="name">Cedric</var> <var id="country">Switzerland</var> </geany> <comments><![CDATA[Our cows are very funny => Drink our milk :-)]]></comments> </root>
Be sure I'll release the source code on my blog as soon as I'm finish with it :) For now I got some questions for you guys : - How can I set the document type ? Ideally, you copy-paste your XML into geany, click on th eplugin-button, it parses the file and set the document type to XML... I'm just lost into the doc... - I compile and run my plugin with Geany 0.16 on Gentoo with libxml2. I sent my .so file to a friend who is on Ubuntu and he tells me that it doesn't appear in the Plugin Manager :( I just joined the .so file in this mail, so if someon can tell me a bit more about that...
And a last information : if someone read french, I just wrote a little blog post http://www.astorm.ch/blog/index.php?post/2009/06/23/Pugin-Geany on how to simply do a plugin on Geany. Hope it helps !
Thanks & Best regards, Cedric Tabin
On Wed, Jun 24, 2009 at 2:43 PM, Frank Lanitz frank@frank.uvena.de wrote:
On Wed, 24 Jun 2009 03:16:04 +0800 Chow Loong Jin hyperair@gmail.com wrote:
On Wednesday 24,June,2009 03:05 AM, Cédric Tabin tabin.cedric@gmail.com wrote:
Hello,
Thanks for the advice :) I just try and it works perfectly !!!
Good to hear. You should consider using a build system to compile your plugins though. And perhaps release your code so that others may benefit from it too. =)
I second this. Maybe we can include it to common geany-plugins distribution in case of its useful for other users also.
Cheers, Frank
-- Frank Lanitz frank@frank.uvena.de _______________________________________________ Geany-devel mailing list Geany-devel@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
On Fri, 7 Aug 2009 18:45:56 +0200 Cédric Tabin tabin.cedric@gmail.com wrote:
Hello geany-guys :)
I come back to you with my (very) small plugin. It allows you to (very) quickly format an XML. The following :
<?xml version="1.0" encoding="utf-8"?><root id="543"><!-- This is a
simple XML sample --><geany user="aname"><var id="name">Cedric</var><var id="country">Switzerland</var></geany><comments><![CDATA[Our cows are very funny => Drink our milk :-)]]></comments></root>
becomes in one click something like that :
<?xml version="1.0" encoding="utf-8"?>
<root id="543"> <!-- This is a simple XML sample --> <geany user="aname"> <var id="name">Cedric</var> <var id="country">Switzerland</var> </geany> <comments><![CDATA[Our cows are very funny => Drink our milk :-)]]></comments> </root>
Cool.
Be sure I'll release the source code on my blog as soon as I'm finish with it :) For now I got some questions for you guys :
- How can I set the document type ? Ideally, you copy-paste your XML
into geany, click on th eplugin-button, it parses the file and set the document type to XML... I'm just lost into the doc...
I guess you are looking for document_set_filetype() described here: http://www.geany.org/manual/reference/document_8h.html#7a2f2bfa1c9fe7d947246...
- I compile and run my plugin with Geany 0.16 on Gentoo with libxml2.
I sent my .so file to a friend who is on Ubuntu and he tells me that it doesn't appear in the Plugin Manager :( I just joined the .so file in this mail, so if someon can tell me a bit more about that...
Its most likely that the so file will be not binary compatible with Geany from Ubuntu due different build of Geany. Recompiling should work. Maybe you should also send the .c file to the devel list as most of ppl around will have the same issues.
And a last information : if someone read french, I just wrote a little blog post http://www.astorm.ch/blog/index.php?post/2009/06/23/Pugin-Geany on how to simply do a plugin on Geany. Hope it helps !
Unfortunately I can't understand any French beside Tarte Flambé ;)
Cheers, Frank
Hello,
Here is the full code of my plugin and the script I use to create the .so file. Let me know if someone can run it on another platform instead of Gentoo. Some feedback would be also really appreciated :-)
Can you just give me the start point into the doc : I wanna add a panel into the preferences for my plugin. How must I proceed ?
Best regards, Cedric
On Fri, Aug 7, 2009 at 7:08 PM, Frank Lanitz frank@frank.uvena.de wrote:
On Fri, 7 Aug 2009 18:45:56 +0200 Cédric Tabin tabin.cedric@gmail.com wrote:
Hello geany-guys :)
I come back to you with my (very) small plugin. It allows you to (very) quickly format an XML. The following :
<?xml version="1.0" encoding="utf-8"?><root id="543"><!-- This is a
simple XML sample --><geany user="aname"><var id="name">Cedric</var><var id="country">Switzerland</var></geany><comments><![CDATA[Our cows are very funny => Drink our milk :-)]]></comments></root>
becomes in one click something like that :
<?xml version="1.0" encoding="utf-8"?>
<root id="543"> <!-- This is a simple XML sample --> <geany user="aname"> <var id="name">Cedric</var> <var id="country">Switzerland</var> </geany> <comments><![CDATA[Our cows are very funny => Drink our milk :-)]]></comments> </root>
Cool.
Be sure I'll release the source code on my blog as soon as I'm finish with it :) For now I got some questions for you guys :
- How can I set the document type ? Ideally, you copy-paste your XML
into geany, click on th eplugin-button, it parses the file and set the document type to XML... I'm just lost into the doc...
I guess you are looking for document_set_filetype() described here:
http://www.geany.org/manual/reference/document_8h.html#7a2f2bfa1c9fe7d947246...
- I compile and run my plugin with Geany 0.16 on Gentoo with libxml2.
I sent my .so file to a friend who is on Ubuntu and he tells me that it doesn't appear in the Plugin Manager :( I just joined the .so file in this mail, so if someon can tell me a bit more about that...
Its most likely that the so file will be not binary compatible with Geany from Ubuntu due different build of Geany. Recompiling should work. Maybe you should also send the .c file to the devel list as most of ppl around will have the same issues.
And a last information : if someone read french, I just wrote a little blog post http://www.astorm.ch/blog/index.php?post/2009/06/23/Pugin-Geany on how to simply do a plugin on Geany. Hope it helps !
Unfortunately I can't understand any French beside Tarte Flambé ;)
Cheers, Frank -- http://frank.uvena.de/en/
Geany-devel mailing list Geany-devel@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
On Sat, 8 Aug 2009 00:43:04 +0200 Cédric Tabin tabin.cedric@gmail.com wrote:
Can you just give me the start point into the doc : I wanna add a panel into the preferences for my plugin. How must I proceed ?
Can you please describe a bit more detailed what you are planning to do?
Thanks, Frank
Hello,
As you can see in the PrettyPrinting.c file, there is some constants for the pretty-printing that I want to externalize. Ideally if the user can set his choices into the Preferences Panel, that would be great :-)
Regards, Cedric
On Sat, Aug 8, 2009 at 1:18 AM, Frank Lanitz frank@frank.uvena.de wrote:
On Sat, 8 Aug 2009 00:43:04 +0200 Cédric Tabin tabin.cedric@gmail.com wrote:
Can you just give me the start point into the doc : I wanna add a panel into the preferences for my plugin. How must I proceed ?
Can you please describe a bit more detailed what you are planning to do?
Thanks, Frank -- http://frank.uvena.de/en/
Geany-devel mailing list Geany-devel@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
Hi,
On Sat, 8 Aug 2009 11:06:15 +0200 Cédric Tabin tabin.cedric@gmail.com wrote:
As you can see in the PrettyPrinting.c file, there is some constants for the pretty-printing that I want to externalize. Ideally if the user can set his choices into the Preferences Panel, that would be great :-)
Adding this to Geany's configuration menu will be tricky and is not the way it should be done. But you can add a dialog to plugin-manager, called by the preferences button. For doing this you need tio implement a plugin_configure() function. You can find a lot examples inside geany-plugins svn at described on http://plugins.geany.org/geany-plugins/
Regards, Frank
On Sat, 8 Aug 2009 00:43:04 +0200 Cédric Tabin tabin.cedric@gmail.com wrote:
Hello,
Here is the full code of my plugin and the script I use to create the .so file. Let me know if someone can run it on another platform instead of Gentoo.
It compiles here, butr not running much (see below)
Some feedback would be also really appreciated :-)
When calling the plugin function, Geany is closing here formating HTML code:
Starting program: /home/frank/local/bin/geany [Thread debugging using libthread_db enabled] processElements : Invalid char 'D' afer '<!' ===== INPUT ===== <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head><title>unbenannt</title><meta http-equiv="content-type" content="text/html;charset=utf-8" /><meta name="generator" content="Geany 0.18" /> </head><body></body></html>
================= inputLength = 355 inputIndex = 0 outputLength = 355 outputIndex = 0
Program exited with code 0376.
Thanks, Frank
Hi Frank,
Thanks for the information ! The code currently doesn't support the DOCTYPE header (I'll add it asap), but should work with other XML. Are you running on Ubuntu ? How did you install the plugin ? My friend compiles it, but even if the so was into the ~/.config/geany/plugins folder, he couldn't see it in Plugin Manager...
Kind regards, Cedric
On Sat, Aug 8, 2009 at 12:43 PM, Frank Lanitz frank@frank.uvena.de wrote:
On Sat, 8 Aug 2009 00:43:04 +0200 Cédric Tabin tabin.cedric@gmail.com wrote:
Hello,
Here is the full code of my plugin and the script I use to create the .so file. Let me know if someone can run it on another platform instead of Gentoo.
It compiles here, butr not running much (see below)
Some feedback would be also really appreciated :-)
When calling the plugin function, Geany is closing here formating HTML code:
Starting program: /home/frank/local/bin/geany [Thread debugging using libthread_db enabled] processElements : Invalid char 'D' afer '<!' ===== INPUT =====
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head><title>unbenannt</title><meta http-equiv="content-type" content="text/html;charset=utf-8" /><meta name="generator" content="Geany 0.18" /> </head><body></body></html>
================= inputLength = 355 inputIndex = 0 outputLength = 355 outputIndex = 0
Program exited with code 0376.
Thanks, Frank -- http://frank.uvena.de/en/
Geany-devel mailing list Geany-devel@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
On Sat, 8 Aug 2009 12:55:58 +0200 Cédric Tabin tabin.cedric@gmail.com wrote:
Thanks for the information ! The code currently doesn't support the DOCTYPE header (I'll add it asap), but should work with other XML.
I this case this shouldn't shut down Geany.
Are you running on Ubuntu ? How did you install the plugin ? My friend compiles it, but even if the so was into the ~/.config/geany/plugins folder, he couldn't see it in Plugin Manager...
I'm using ./compile && cp XMLFormatter.so ~/local/lib/geany/ Depending on the version of Geany the folder isn't .config/geany but ~/.geany
Thanks, Frank
Hi Frank,
Okay, here is an update => in case of invalid char, it won't shut down 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 !
Best regards, Cedric
On Sat, Aug 8, 2009 at 1:24 PM, Frank Lanitz frank@frank.uvena.de wrote:
On Sat, 8 Aug 2009 12:55:58 +0200 Cédric Tabin tabin.cedric@gmail.com wrote:
Thanks for the information ! The code currently doesn't support the DOCTYPE header (I'll add it asap), but should work with other XML.
I this case this shouldn't shut down Geany.
Are you running on Ubuntu ? How did you install the plugin ? My friend compiles it, but even if the so was into the ~/.config/geany/plugins folder, he couldn't see it in Plugin Manager...
I'm using ./compile && cp XMLFormatter.so ~/local/lib/geany/ Depending on the version of Geany the folder isn't .config/geany but ~/.geany
Thanks, Frank -- http://frank.uvena.de/en/
Geany-devel mailing list Geany-devel@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
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
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). - How do I get the depth of the selected node ?
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@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@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
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@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@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
Geany-devel mailing list Geany-devel@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
On Sun, 9 Aug 2009 18:37:34 +0200, Cédric wrote:
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).
- How do I get the depth of the selected node ?
Ah ok, I didn't think of these two problems. It also was just an idea, no need to implement this if it isn't easily possible.
In addition to Philipp's suggestion about writing an own parser, GLib also has a simple XML parser builtin. Not sure whether it is suitable for your needs but maybe it's worth having a look, then you could also ditch the external dependency on libxml. But again, just an idea.
I just sent you a request to join the geany project on sourceforge.
Handled, added and confirmed to you via PM :).
Regards, Enrico
Hello,
Yep I currently just use libxml to check if the document contains a valid XML. Then my script process the pretty-printing on a char* buffer and I do the parsing manually (but I don't need to verify XML). The idea is also to provide a simple XML PrettyPrinter script in C. So far I had never found one that can suit to my needs... I'll commit all my sources to the svn asap :-) If you have any advices, just tell me so I can learn !
Thanks & best regards, Cedric
2009/8/9 Enrico Tröger enrico.troeger@uvena.de
On Sun, 9 Aug 2009 18:37:34 +0200, Cédric wrote:
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).
- How do I get the depth of the selected node ?
Ah ok, I didn't think of these two problems. It also was just an idea, no need to implement this if it isn't easily possible.
In addition to Philipp's suggestion about writing an own parser, GLib also has a simple XML parser builtin. Not sure whether it is suitable for your needs but maybe it's worth having a look, then you could also ditch the external dependency on libxml. But again, just an idea.
I just sent you a request to join the geany project on sourceforge.
Handled, added and confirmed to you via PM :).
Regards, Enrico
-- Get my GPG key from http://www.uvena.de/pub.asc
Geany-devel mailing list Geany-devel@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
Hi Cédric,
On Sun, 9 Aug 2009 22:46:33 +0200 Cédric Tabin tabin.cedric@gmail.com wrote:
I'll commit all my sources to the svn asap :-) If you have any advices, just tell me so I can learn !
Thanks for committing. Since a couple of weeks we got an combined plugins project inside geany-plugins svn which makes it more easy for distributions as well as for normal users providing and using a number of Geany plugins with a common build system and a common translation process. Of course this will cause a lost of independency for each plugin joning the common release, but with a big win for developers as well as users I guess. I don't know how you are feeling about this, but maybe you can move your plugin code to the trunk/geany-plugins path in svn so it will be added to next big release of plugins. The new path would be something like trunk/geany-plugins/pretty-printer/ and you can use the svn mv function for doing it.
Regards, Frank
Hi Franck,
I put my plugin where you said already => http://geany-plugins.svn.sourceforge.net/viewvc/geany-plugins/trunk/pretty-p... wait for your commit of the build system, so I can try it on my computer :-)
Regards, Cedric
On Mon, Aug 10, 2009 at 11:53 AM, Frank Lanitz frank@frank.uvena.de wrote:
Hi Cédric,
On Sun, 9 Aug 2009 22:46:33 +0200 Cédric Tabin tabin.cedric@gmail.com wrote:
I'll commit all my sources to the svn asap :-) If you have any advices,
just
tell me so I can learn !
Thanks for committing. Since a couple of weeks we got an combined plugins project inside geany-plugins svn which makes it more easy for distributions as well as for normal users providing and using a number of Geany plugins with a common build system and a common translation process. Of course this will cause a lost of independency for each plugin joning the common release, but with a big win for developers as well as users I guess. I don't know how you are feeling about this, but maybe you can move your plugin code to the trunk/geany-plugins path in svn so it will be added to next big release of plugins. The new path would be something like trunk/geany-plugins/pretty-printer/ and you can use the svn mv function for doing it.
Regards, Frank -- Frank Lanitz frank@frank.uvena.de _______________________________________________ Geany-devel mailing list Geany-devel@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
Hi,
On Mon, 10 Aug 2009 11:56:57 +0200 Cédric Tabin tabin.cedric@gmail.com wrote:
I put my plugin where you said already => http://geany-plugins.svn.sourceforge.net/viewvc/geany-plugins/trunk/pretty-p...
The correct path on viewvc would be http://geany-plugins.svn.sourceforge.net/viewvc/geany-plugins/trunk/geany-pl...
If you like I can do it for you.
Thanks, Frank
Hello,
It's all right, I did it :-)
Thanks, Cedric
On Mon, Aug 10, 2009 at 12:25 PM, Frank Lanitz frank@frank.uvena.de wrote:
Hi,
On Mon, 10 Aug 2009 11:56:57 +0200 Cédric Tabin tabin.cedric@gmail.com wrote:
I put my plugin where you said already =>
http://geany-plugins.svn.sourceforge.net/viewvc/geany-plugins/trunk/pretty-p...
The correct path on viewvc would be
http://geany-plugins.svn.sourceforge.net/viewvc/geany-plugins/trunk/geany-pl...
If you like I can do it for you.
Thanks, Frank -- Frank Lanitz frank@frank.uvena.de _______________________________________________ Geany-devel mailing list Geany-devel@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
On Mon, 10 Aug 2009 12:38:40 +0200 Cédric Tabin tabin.cedric@gmail.com wrote:
It's all right, I did it :-)
Cool. Thanks.
Frank
On Monday 10,August,2009 05:56 PM, Cédric Tabin wrote:
Hi Franck,
I put my plugin where you said already => http://geany-plugins.svn.sourceforge.net/viewvc/geany-plugins/trunk/pretty-p... I'll wait for your commit of the build system, so I can try it on my computer :-)
Hi Cédric,
I've just integrated your plugin into the Autotools build system. However, your plugin still does not compile. Here are the issues preventing it from compiling: 1. Declaration of variables inside a for loop In C++, we like this: for (int i = 0; ...
In C, we don't. We do this: int i; for (i = 0; ...
2. Bad #include. We don't like to #include .c files. I suspect this is a typo, which causes multiple definitions of a function, resulting in problems linking. See line 27 of pretty-printer/src/Plugin.c: #include "PrettyPrinter.c".
3. Missing decls for TRUE and FALSE. TRUE and FALSE are defined in the header "glib/gmacros.h", found in /usr/include/glib-2.0 on Debian and its derivatives. I suspect you forgot to include this in PrettyPrinter.c
A minor issue that should be fixed anyway: 1. Usage of the "boolean" type Rather than #define boolean int, how about using the gboolean datatype, found in the header "glib/gtypes.h", found in /usr/include/glib-2.0?
Now for some cosmetic issues: 1. Long lines Long lines are a pain to read and destroy the entire purpose of indentation if they wrap. I believe the general consensus is 80 characters per line. I'd suggest reducing your lines to fit that length, and chopping some lines up into smaller lines.
Trivia: A dot matrix printer can only have 80 characters in a line before they get wrapped!
2. Copyright headers Your files have a license header, which is good. However, for GPL files, it is generally customary to have something like this:
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
This block is found near the end of the GPL license text. A copy can be found in /usr/share/common-licenses/GPL-2 on Debian and its derivatives.
I would have fixed the compilation issues for you, but I figured that since you mentioned you'd like to hear suggestions so you can learn, it would be good for you to fix these yourself. :-)
Hello Chow,
Thanks for your feedback :-) I've fixed the issues you mentionned (I hope) and upgraded a little bit my code. Since now I always used my small compile script which is very simple :
#!/bin/sh
source="src/Plugin.c" output="XMLPrettyPrinter"
gcc -std=c99 -o "$output.o" -Wall -c -fpic "$source" `pkg-config --cflags geany libxml-2.0` gcc -shared -o "$output.so" "$output.o" `pkg-config --libs geany libxml-2.0`
And so far there was no compile error. Can you explain me how to use the automatic build so I won't commit unbuildable code ? One more question : in my Plugin.c file, I #include the PrettyPrinter.c file because at if I use PrettyPrinter.h, at runtime Geany said me that it was unable to find the reference to my PrettyPrinter options... Maybe something wrong in my compilation script ? That's a problem of linking isn't it ?
I you have any other comment, please let me know :-)
Best regards, Cedric
On Mon, Aug 10, 2009 at 5:46 PM, Chow Loong Jin hyperair@gmail.com wrote:
On Monday 10,August,2009 05:56 PM, Cédric Tabin wrote:
Hi Franck,
I put my plugin where you said already =>
http://geany-plugins.svn.sourceforge.net/viewvc/geany-plugins/trunk/pretty-p...
I'll wait for your commit of the build system, so I can try it on my computer :-)
Hi Cédric,
I've just integrated your plugin into the Autotools build system. However, your plugin still does not compile. Here are the issues preventing it from compiling:
- Declaration of variables inside a for loop
In C++, we like this: for (int i = 0; ...
In C, we don't. We do this: int i; for (i = 0; ...
- Bad #include.
We don't like to #include .c files. I suspect this is a typo, which causes multiple definitions of a function, resulting in problems linking. See line 27 of pretty-printer/src/Plugin.c: #include "PrettyPrinter.c".
- Missing decls for TRUE and FALSE.
TRUE and FALSE are defined in the header "glib/gmacros.h", found in /usr/include/glib-2.0 on Debian and its derivatives. I suspect you forgot to include this in PrettyPrinter.c
A minor issue that should be fixed anyway:
- Usage of the "boolean" type
Rather than #define boolean int, how about using the gboolean datatype, found in the header "glib/gtypes.h", found in /usr/include/glib-2.0?
Now for some cosmetic issues:
- Long lines
Long lines are a pain to read and destroy the entire purpose of indentation if they wrap. I believe the general consensus is 80 characters per line. I'd suggest reducing your lines to fit that length, and chopping some lines up into smaller lines.
Trivia: A dot matrix printer can only have 80 characters in a line before they get wrapped!
- Copyright headers
Your files have a license header, which is good. However, for GPL files, it is generally customary to have something like this:
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
This block is found near the end of the GPL license text. A copy can be found in /usr/share/common-licenses/GPL-2 on Debian and its derivatives.
I would have fixed the compilation issues for you, but I figured that since you mentioned you'd like to hear suggestions so you can learn, it would be good for you to fix these yourself. :-)
-- Kind regards, Chow Loong Jin
Geany-devel mailing list Geany-devel@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
On Tuesday 11,August,2009 03:51 AM, Cédric Tabin wrote:
Hello Chow,
Thanks for your feedback :-) I've fixed the issues you mentionned (I hope) and upgraded a little bit my code. Since now I always used my small compile script which is very simple :
#!/bin/sh
source="src/Plugin.c" output="XMLPrettyPrinter"
gcc -std=c99 -o "$output.o" -Wall -c -fpic "$source" `pkg-config --cflags geany libxml-2.0` gcc -shared -o "$output.so" "$output.o" `pkg-config --libs geany libxml-2.0`
And so far there was no compile error. Can you explain me how to use the automatic build so I won't commit unbuildable code ? One more question : in my Plugin.c file, I #include the PrettyPrinter.c file because at if I use PrettyPrinter.h, at runtime Geany said me that it was unable to find the reference to my PrettyPrinter options... Maybe something wrong in my compilation script ? That's a problem of linking isn't it ?
There is something wrong with your compilation script. Generally all .c files are compiled and linked together, where all .c files are mapped into .o files respectively. Your script omits the PrettyPrinter.c file, and hence cannot find references if PrettyPrinter.c is not #included, because only the function prototypes are in PrettyPrinter.h (definitions are in PrettyPrinter.c)
As for the issue with the for loop, the reason for that happening is because gcc defaults to -std=gnu89, which is based on the C90 standard, whereas declarations within the for loop only work with -std=c99 and above. I think it's best to stick to this standard (C90) for portability reasons.
Anyway, there are actually two build systems in place. One uses Autotools, and the other uses Waf. To use the Autotools build system, you run autogen.sh once in trunk/geany-plugins to generate the configure script and Makefiles, then cd into your plugin directory and run "make" to compile. This can be repeated in an edit-make-edit-make kind of cycle, and I think you'll find this better than your script because it only recompiles the parts which have changed. To install, run "make install" as root. To test the installation with an alternate root directory, you may use "make DESTDIR=/path/to/alternate/root install".
To use the Waf build system, see the README.waf document in trunk/geany-plugins.
On Tue, 11 Aug 2009 04:26:51 +0800, Chow wrote:
Hey,
attached is a little patch which cleans up the includes and improves ordering of the included header files. The main change is to include "geany.h" very early, this header will implicitly include most of the GLib and GTK headers you need. So, there is no need to explicitly include something like <glib/gmacros.h> which is deprecated due to GTK's single header policy anyway. I don't want to bore you with details, just make "geany.h" your first include in general should do the trick.
In the future, i.e. once Geany 0.18 is released, things will get a lot easier, then you only need to include "geanyplugin.h" which includes most other necessary Geany and GTK headers. The API docs, especially the howto describe this issue as well, IIRC.
As for the issue with the for loop, the reason for that happening is because gcc defaults to -std=gnu89, which is based on the C90 standard, whereas declarations within the for loop only work with -std=c99 and above. I think it's best to stick to this standard (C90) for portability reasons.
While there are probably not many people out there (anymore) who use a C89/C90 compiler, there are at least a few of them. And so we try to keep the Geany code compiling with gcc -ansi, i.e. compatible with C89. Nobody is forced to do the same with plugins, but it just makes it easier for users. The current code still doesn't compile with a pure C89 compiler because C89 doesn't allow to mix code and variable declarations. Cédric, it's completely up to you whether you want to "fix" this or just keep it as it is.
If you want to see the warnings I'm talking about, just check http://nightly.geany.org/misc/build_gtk28_plugins_stderr.log tomorrow (after August 11, 04:00 UTC). There should appear a few warnings. But again, it's completely up to you whether to remove them or to keep them.
Regards, Enrico
Hi there,
It's me again :-) I just have some questions about committing on Sourceforge. Is there any convention into messages ? May we commit as much as we want ? Are there some (strict) limitations ? Probably I'll only commit files for my plugin but...
Thanks & regards, Cedric
ps. I can now compile using the automated build tool :-) great !!!
2009/8/10 Enrico Tröger enrico.troeger@uvena.de
On Tue, 11 Aug 2009 04:26:51 +0800, Chow wrote:
Hey,
attached is a little patch which cleans up the includes and improves ordering of the included header files. The main change is to include "geany.h" very early, this header will implicitly include most of the GLib and GTK headers you need. So, there is no need to explicitly include something like <glib/gmacros.h> which is deprecated due to GTK's single header policy anyway. I don't want to bore you with details, just make "geany.h" your first include in general should do the trick.
In the future, i.e. once Geany 0.18 is released, things will get a lot easier, then you only need to include "geanyplugin.h" which includes most other necessary Geany and GTK headers. The API docs, especially the howto describe this issue as well, IIRC.
As for the issue with the for loop, the reason for that happening is because gcc defaults to -std=gnu89, which is based on the C90 standard, whereas declarations within the for loop only work with -std=c99 and above. I think it's best to stick to this standard (C90) for portability reasons.
While there are probably not many people out there (anymore) who use a C89/C90 compiler, there are at least a few of them. And so we try to keep the Geany code compiling with gcc -ansi, i.e. compatible with C89. Nobody is forced to do the same with plugins, but it just makes it easier for users. The current code still doesn't compile with a pure C89 compiler because C89 doesn't allow to mix code and variable declarations. Cédric, it's completely up to you whether you want to "fix" this or just keep it as it is.
If you want to see the warnings I'm talking about, just check http://nightly.geany.org/misc/build_gtk28_plugins_stderr.log tomorrow (after August 11, 04:00 UTC). There should appear a few warnings. But again, it's completely up to you whether to remove them or to keep them.
Regards, Enrico
-- Get my GPG key from http://www.uvena.de/pub.asc
Geany-devel mailing list Geany-devel@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
On Wednesday 12,August,2009 06:25 AM, Cédric Tabin wrote:
Hi there,
It's me again :-) I just have some questions about committing on Sourceforge. Is there any convention into messages ? May we commit as much as we want ? Are there some (strict) limitations ? Probably I'll only commit files for my plugin but...
I would think that as long as you don't mess up code maintained by others, it's fine, just commit as much as you want. :-)
Thanks & regards, Cedric
ps. I can now compile using the automated build tool :-) great !!!
Great to hear.
Hi,
On Wed, 12 Aug 2009 00:25:07 +0200 Cédric Tabin tabin.cedric@gmail.com wrote:
It's me again :-) I just have some questions about committing on Sourceforge. Is there any convention into messages ?
No real convention. I like to add the plugin name I've done something on to my commit message whereas others don't do so. Just try to be clear inside message so "Some minor update" might not the best choice.
May we commit as much as we want ?
This was under discussion before. You will need to find a compromise between the extremes: Its not useful to commit every singe linge change but a commit including 20 new features as well as 10 bug fixes is also not a too good idea. Usually we try to commit one feature with one commit but this is depending on the feature and other environmental parameters. Bigger features might be useful to develop inside an special branch.
Are there some (strict) limitations ? Probably I'll only commit files for my plugin but...
No real restriction, but we try to only commit changes direct to plugins we are maintaining personal. In every other case we usually sending patches to maintainer of the plugin.
Regards, Frank
On Wed, 12 Aug 2009 09:59:33 +0200, Frank wrote:
Are there some (strict) limitations ? Probably I'll only commit files for my plugin but...
No real restriction, but we try to only commit changes direct to plugins we are maintaining personal. In every other case we usually sending patches to maintainer of the plugin.
Usually there is just no need to commit changes into foreign code. And based on experience, in most cases it's better to discuss the changes with the maintainer before and let him make the final decision whether or not to apply the changes. Often maintainer know their code better and maybe have a different point of view in fixing or extending the code. So, talking to the maintainer and sending in a patch should be the way to go in the first place, usually.
Regards, Enrico