https://wiki.codeblocks.org/index.php?title=Creating_a_plugin_that_actually_does_something&feed=atom&action=historyCreating a plugin that actually does something - Revision history2024-03-29T10:58:37ZRevision history for this page on the wikiMediaWiki 1.35.0https://wiki.codeblocks.org/index.php?title=Creating_a_plugin_that_actually_does_something&diff=4149&oldid=prevArtojon: removed extra category2006-11-11T19:29:02Z<p>removed extra category</p>
<table class="diff diff-contentalign-left diff-editfont-monospace" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 19:29, 11 November 2006</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>
<td colspan="2" class="diff-lineno">Line 1:</td></tr>
<tr><td class='diff-marker'>−</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del style="font-weight: bold; text-decoration: none;">[[Category:Developer Documentation]]</del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>[[Category:Plugin development]]</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>[[Category:Plugin development]]</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>''NOTE: this article is a work in progress.''</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>''NOTE: this article is a work in progress.''</div></td></tr>
</table>Artojonhttps://wiki.codeblocks.org/index.php?title=Creating_a_plugin_that_actually_does_something&diff=3847&oldid=prevMandrav: Changed plugin type from "Tool" to "Generic"2006-09-22T11:07:13Z<p>Changed plugin type from "Tool" to "Generic"</p>
<table class="diff diff-contentalign-left diff-editfont-monospace" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 11:07, 22 September 2006</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l78" >Line 78:</td>
<td colspan="2" class="diff-lineno">Line 78:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>In this page, we must decide what type of plugin we want to make as well as its name. For the name enter "InterpretedLangs".</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>In this page, we must decide what type of plugin we want to make as well as its name. For the name enter "InterpretedLangs".</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>Also, <del class="diffchange diffchange-inline">leave </del>the plugin's type to "<del class="diffchange diffchange-inline">Tool</del>". For more info on the various plugin types and their differences, see the Code::Blocks SDK documentation.</div></td><td class='diff-marker'>+</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>Also, <ins class="diffchange diffchange-inline">set </ins>the plugin's type to "<ins class="diffchange diffchange-inline">Generic</ins>". For more info on the various plugin types and their differences, see the Code::Blocks SDK documentation.</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>Finally, make sure you check the <del class="diffchange diffchange-inline">"Provides configuration dialog" option</del>. This will allow our plugin to add a configuration page in the Code::Blocks settings dialogs.</div></td><td class='diff-marker'>+</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>Finally, make sure you check the <ins class="diffchange diffchange-inline">options as seen in the picture above</ins>. This will allow our plugin to add a configuration page in the Code::Blocks settings dialogs <ins class="diffchange diffchange-inline">and generally integrate nicer</ins>.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Click "Next".</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Click "Next".</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td></tr>
</table>Mandravhttps://wiki.codeblocks.org/index.php?title=Creating_a_plugin_that_actually_does_something&diff=3846&oldid=prevMandrav: Initial text2006-09-22T10:51:28Z<p>Initial text</p>
<p><b>New page</b></p><div>[[Category:Developer Documentation]]<br />
[[Category:Plugin development]]<br />
''NOTE: this article is a work in progress.''<br />
<br />
<br />
In this article we are going to create a "real" plugin. That is a plugin that actually does something more elaborate than just greeting the world ;).<br />
<br />
<br />
== Interpreted languages support plugin ==<br />
<br />
We are going to create a plugin that will add support for interpreted languages in Code::Blocks. "Interpreted" are considered the languages that do not generate native machine code but rather generate an intermediate code that an interpreter understands and converts to native machine code at runtime.<br />
<br />
<br />
=== Planning stage ===<br />
<br />
While we 're in the early development stage (a.k.a. planning), let's decide what this plugin will be able to do and what it won't.<br />
This plugin should allow the user to:<br />
<br />
* define as many interpreters as needed<br />
* associate specific file extensions with each interpreter<br />
* run any interpreter's shell<br />
* run any interpreter with the appropriate arguments to operate on or accept as input a source file (more on that below)<br />
<br />
As you see, while we 're not over-complicating things, we should hopefully end up with a really useful plugin :).<br />
<br />
<br />
==== Data structures ====<br />
<br />
Let's decide now what structures we will need (code-wise) to store the above requirements and their relationships.<br />
<br />
<br />
'''Requirement: define as many interpreters as needed.'''<br />
<br />
Since we don't want to impose any limits, we need a dynamic container of some sort. I guess std::vector will suite us just fine :).<br />
<br />
'''Requirement: associate specific file extensions with each interpreter.'''<br />
<br />
A simple semicolon-separated string will suffice. E.g. <tt>"*.py;*.pyc"</tt>.<br />
<br />
'''Requirement: run any interpreter's shell.'''<br />
<br />
A string is enough. E.g. "C:\Python\Python24\pythonw.exe".<br />
<br />
'''Requirement: run any interpreter with the appropriate arguments to operate on or accept as input a source file.'''<br />
<br />
So we need a dynamic array holding somekind of struct defining the available actions. Because nothing beats a good example, here is the most common (and important action): "Run". This action would cause the interpreter to be launched with the source file as argument and run it.<br />
<br />
struct InterpreterAction<br />
{<br />
wxString name; // the action's name, e.g. "Run"<br />
wxString command; // the command, e.g. "$interpreter --run $file"<br />
};<br />
<br />
The final struct that glues all of the above together is this:<br />
struct Interpreter<br />
{<br />
wxString name; // a friendly name for the interpreter<br />
wxString executable; // the full path to the interpreter's executable<br />
wxString extensions; // a semicolon-separated list of extension wildcards (e.g. "*.py;*.pyc")<br />
std::vector<InterpreterAction> actions; // an array of possible actions with this interpreter<br />
};<br />
<br />
<br />
=== Implementation stage ===<br />
<br />
Let's roll our sleeves up and start working on this plugin :).<br />
<br />
First thing we need is to create a new project for this plugin. Thankfully, the Code::Blocks Team has already provided us with a nice and easy wizard that will generate all the boilerplate code for us. Let's get going.<br />
<br />
Click on "File->New->Project" and a dialog with the available project wizards will appear. Select the "Code::Blocks plugin" and click "Go".<br />
[[Image:Intlng_1.png]]<br />
<br />
This will start the Code::Blocks plugin wizard. The first page of this wizard displays some important info which you should read. When you 're done reading, click "Next".<br />
<br />
Now enter the plugin's title, e.g. "Interpreted languages support". If you don't need to edit anything else in this page (like the destination directory), click "Next".<br />
<br />
[[Image:Intlng_2.png]]<br />
<br />
In this page, we must decide what type of plugin we want to make as well as its name. For the name enter "InterpretedLangs".<br />
Also, leave the plugin's type to "Tool". For more info on the various plugin types and their differences, see the Code::Blocks SDK documentation.<br />
Finally, make sure you check the "Provides configuration dialog" option. This will allow our plugin to add a configuration page in the Code::Blocks settings dialogs.<br />
Click "Next".<br />
<br />
In the next page, fill in any info you deem appropriate for this plugin. Click "Next".<br />
<br />
In the compiler page, select (if not already selected) the "GCC" compiler because that's what Code::Blocks is built with.<br />
<br />
Finally click "Finish".<br />
<br />
You should find yourself in Code::Blocks again with the new plugin project open and ready for editing :).<br />
But first let's see if this compiles. If it doesn't, don't bother reading more. This article assumes a valid development setup from your side...<br />
<br />
Note that the Code::Blocks plugin wizard was kind enough to add some post-build commands that will copy the plugin and its resources where Code::Blocks expects to find them. It even set Code::Blocks as a "host" application for our plugin (which is a dynamic library and can't run on its own). This means that after you build the plugin, you can "run" it too :).<br />
<br />
Go on, build and run it. Does it work? OK, let's move on :)<br />
<br />
<br />
<br />
<br />
To be continued...<br />
<br />
[[User:Mandrav|Mandrav]] 06:51, 22 September 2006 (EDT)</div>Mandrav