Author Topic: Plugin for a Programming Language  (Read 36404 times)

Offline igorevc

  • Multiple posting newcomer
  • *
  • Posts: 23
Plugin for a Programming Language
« on: January 27, 2009, 01:45:18 pm »
Good day.

I want to create a plugin for Code::Blocks for a programming language that has the following features:

- New project type and new file types
- Testing and debugging facilitations

I already made the Hello World tutorial but I need some more info to make my project possible.
Can you help me out?

Thank you for your attention.

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Plugin for a Programming Language
« Reply #1 on: January 27, 2009, 03:48:22 pm »
what programming language? compiled or interpreted?

files types are handled automatically (more or less - at present, there's no programmatic way to add new file types for the project tree). you can create project wizards without creating a plugin.

a plugin would be suitable for adding testing or debugging facilities. I put together a "proof-of-concept" python debugger a couple of years back, which simply parses the output of the command line debugger (pdb) in order to offer familiar gui interaction. what do you have in mind for testing?

Offline igorevc

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: Plugin for a Programming Language
« Reply #2 on: January 27, 2009, 05:03:10 pm »
If you need to know, it's a interpreted.

But the plugin must add new project types and new file types.

For testing, it should create a console that interpretates commands and return the possible results.

I need what I asked to make a complete plugin.

By the way, is there a way to incorporate the console on "Log & others"?

Once more, I thank you for your attention.

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Plugin for a Programming Language
« Reply #3 on: January 27, 2009, 06:45:15 pm »
If you need to know, it's a interpreted.

I asked because it makes a difference. CB's project infrastructure was designed for compiled languages. Interpreted languages don't need all of that complexity. So what sort of project support do you need: just a container to say these files belong to this project?

Quote
But the plugin must add new project types and new file types.

you could deploy a project wizard along with your plugin. It wouldn't be all that difficult to tweak the CB SDK to add the ability to add file types programmatically (file a patch if you want)

Quote
For testing, it should create a console that interpretates commands and return the possible results.
...
By the way, is there a way to incorporate the console on "Log & others"?

You could use existing logs to send output (for example, commands that you set up on the tools menu can be redirected to the log)

Alternatively, you could create your own frame or window that handles process I/O. I've written a plugin called ShellExtensions that does just that for arbitrary commands. (you can find links to these plugins at the project page in my sig. I'm in the process of getting some of this code ready to move into C::B proper)
« Last Edit: January 27, 2009, 07:34:44 pm by dmoore »

Offline igorevc

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: Plugin for a Programming Language
« Reply #4 on: January 27, 2009, 07:24:14 pm »
On the project part, I'll need a file container and to verify errors.

I really want my plugin to extend the project choices.

Thank you so much for your attention.

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Plugin for a Programming Language
« Reply #5 on: January 27, 2009, 09:33:43 pm »
On the project part, I'll need a file container and to verify errors.

one way to proceed would be for your projects to offer two targets (or two sets of targets): one for the actual program, and one for its tests. users could then select which target they want to run. the problem with this is that C::B targets can't at this time be set up to pass their output to a plugin for further processing. the other problem is that if you use the project system in this way, C::B will expect you to choose a compiler for the project (or use an existing compiler) and present a bunch of unwanted and confusing compiler options to your users.

Offline igorevc

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: Plugin for a Programming Language
« Reply #6 on: January 27, 2009, 10:22:47 pm »
I could just verify errors during the build. It would be easier, don't you think?

Thank you for your attention.

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Plugin for a Programming Language
« Reply #7 on: January 27, 2009, 11:14:22 pm »
I could just verify errors during the build. It would be easier, don't you think?

Thank you for your attention.

ok, so you would use compile to run the tests. I suppose that would work. Try playing around with the compiler toolchain to get this working...

Offline igorevc

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: Plugin for a Programming Language
« Reply #8 on: January 28, 2009, 12:19:02 am »
"compiler toolchain"?
I'm a bit confused. Explain better.

Once again, thank you for your attention.

Offline igorevc

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: Plugin for a Programming Language
« Reply #9 on: January 28, 2009, 12:30:33 am »
I made a research on Code::Blocks Plugin Development and I found what I was looking for:

http://wiki.codeblocks.org/index.php?title=Creating_a_plugin_that_actually_does_something

But the tutorial is incomplete. Is there an updated (and completed) version of the tutorial?

Thank you for your attention.

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Plugin for a Programming Language
« Reply #10 on: January 28, 2009, 05:26:40 am »
I made a research on Code::Blocks Plugin Development and I found what I was looking for:

http://wiki.codeblocks.org/index.php?title=Creating_a_plugin_that_actually_does_something

But the tutorial is incomplete. Is there an updated (and completed) version of the tutorial?

unfortunately plugin development documentation is in a sorry state (lots of incomplete stuff). The best way to learn is just to download code::blocks source and inspect some of the plugins.

We can help you, but you need to give us a better idea of what you want to do. I suggest writing up a short description that more precisely lays out a minimal sample project and the features that you want to support.

"compiler toolchain"?
I'm a bit confused. Explain better.

take a look at Settings -> Compiler and Debugger -> "Other Settings" tab -> Advanced Options

that will give you an idea of how you might be able to abstract the concept of a compiler to your purposes. that could save you a bunch of coding time.

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Plugin for a Programming Language
« Reply #11 on: January 28, 2009, 05:38:19 am »
also look at

http://wiki.codeblocks.org/index.php?title=Adding_support_for_non_C/C%2B%2B_files_to_the_build_system

and for the record:

http://wiki.codeblocks.org/index.php?title=Creating_a_plugin_that_actually_does_something

was written by the project leader to educate me on how to write a plugin. :) If you are interested in that specific example, it actually became the basis for the "ShellExtensions" plugin (which does a lot more than just launch external programs: it has a file manager, supports custom commands and redirection of command output to a dockable window). I'm working on getting that plugin ready for the main cb repository. Right now, you can find it by following the link to the project page in my sig.

Offline igorevc

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: Plugin for a Programming Language
« Reply #12 on: January 28, 2009, 05:49:01 pm »
I'm more interessed in the code itself.
Could you put also the code?

Thank you for your attention.

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Plugin for a Programming Language
« Reply #13 on: January 28, 2009, 06:23:10 pm »
it's an open source project. the source is at the project page (look under SVN)

EDIT: Let me warn you that the code needs a lot of cleanup
« Last Edit: January 28, 2009, 06:27:15 pm by dmoore »

Offline igorevc

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: Plugin for a Programming Language
« Reply #14 on: February 18, 2009, 07:25:49 pm »
Good afternoon.

Just for now, I need to make a plugin that:
 - when plugged to Code::Blocks, it will add a new project type and new file extensions
 - when unplugged to Code::Blocks, the new project type and new file extensions will disappear

Is it possible? If so, can someone help me out?

I thank you for your attention.

Offline igorevc

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: Plugin for a Programming Language
« Reply #15 on: February 19, 2009, 12:09:27 pm »
Good day.

Is there a way to register a new project wizard through a plugin?
If not, how can I make a notion of a project?

Thank you for your attention.

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Plugin for a Programming Language
« Reply #16 on: February 19, 2009, 03:29:09 pm »
take a look at how yop does it in his qtWorkbench plugin

Offline igorevc

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: Plugin for a Programming Language
« Reply #17 on: February 27, 2009, 04:45:27 pm »
Good afternoon.

I need that my plugin use the plugin "scriptedwizard". 
Once my plugin is attached to Code::Blocks, my plugin communicates with "scriptedwizard"
and tries to read my own config.script with just my own wizards.
Since "scriptedwizard", when attached to Code::Blocks, reads his own config.script,
I had the idea to use the "scriptedwizard" plugin to add more wizards.
The question is: is my plan feasable? If so, how can my plugin communicate with "scriptedwizard"?

Thank you for your attention.

Offline igorevc

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: Plugin for a Programming Language
« Reply #18 on: February 28, 2009, 06:36:41 pm »
Good afternoon.

I made the question because I think that using the Code::Blocks "scriptedwizard" can be better than
defining our own version of "scriptedwizard".

Can anyone give me an answer?

Thank you for your attention.

Offline igorevc

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: Plugin for a Programming Language
« Reply #19 on: March 03, 2009, 07:39:23 pm »
Good afternoon.

I have solved, in a manual way, the wizards' problems.

I have a question regarding lexers. I want to create a lexer for an interpretted language, but it seems that
an existing lexer possesses the same file mask as the files this plugin will handle. Same mask but different syntax.
Is that a problem? If so, how can I handle it?

Thank you for your attention.

Offline igorevc

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: Plugin for a Programming Language
« Reply #20 on: March 12, 2009, 06:04:18 pm »
Good afternoon.

I need to create a syntax highlight for my interpretted language that, unfortunatelly, isn't included on wxscintilla.
How can I create a syntax highlight?

Thank you for your attention.

Offline igorevc

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: Plugin for a Programming Language
« Reply #21 on: April 03, 2009, 08:14:21 pm »
Good afternoon.

I'll need that my plugin create a textbox that does the following:
- Keeps the history of recent used commands (throught a list)
- Has a button that, when pressed, executes the current command in the textbox and adds the command to the history
- Is dockable and in the top of the Code::Blocks logs

Can anyone help me out, at least with the textbox?

Thank you for your attention.

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Plugin for a Programming Language
« Reply #22 on: April 03, 2009, 09:42:11 pm »
Good afternoon.

I'll need that my plugin create a textbox that does the following:
- Keeps the history of recent used commands (throught a list)
- Has a button that, when pressed, executes the current command in the textbox and adds the command to the history
- Is dockable and in the top of the Code::Blocks logs

Can anyone help me out, at least with the textbox?

Thank you for your attention.

wxTextCtrl -the question is where do you want to put it? In a toolbar? In a dialog? Take a look at some of the plugins to see how they do it.

also for lexing languages not already supported by scintilla you have to write the lexer yourself. go to the scintilla site to learn how.

Offline igorevc

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: Plugin for a Programming Language
« Reply #23 on: April 04, 2009, 12:27:34 am »
I would like to put it in a window, which would be docked near the logs.
I'm pretty sure that what I need is an editable listbox. Why? Because I want to write the command, push a button and store the used commands. If I want to use the same command, I need to dropdown the list and select it.

About the lexer, I'll postpone because it's not that important.

Offline igorevc

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: Plugin for a Programming Language
« Reply #24 on: April 23, 2009, 05:22:58 pm »
Good afternoon, dmoore.

I downloaded your PowerShell plugin, and played with it.
It seems that it is not yet capable to read and write commands in window mode, unless I'm doing something wrong.
For instance, I tried the cmd.exe and I can't write anything at all on the flatnotebook.
How can I (or you) fix it?

Thank you for your attention.

UPDATE:

It seems, now, that cmd.exe works but it doesn't take any input.
« Last Edit: April 23, 2009, 05:50:10 pm by igorevc »

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Plugin for a Programming Language
« Reply #25 on: April 24, 2009, 03:02:04 am »
It seems that it is not yet capable to read and write commands in window mode, unless I'm doing something wrong.

it was capable. either I or something in the C::B internals broke something to do with wxKeyEvent interception. I'll look into it.

one thing you need to be wary when you run interpreters is calling the interpreter in an "unbuffered" mode. for e.g., I call python with "python -u myfile.py"

more generally trying to handle interactive I/O the way the powershell plugin does using the limited wxExecute implementation is not really the best way to go. a better approach requires some sort of platform specific terminal emulation, maybe embedding a pre-built terminal emulator inside C::B?

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Plugin for a Programming Language
« Reply #26 on: April 24, 2009, 08:09:31 pm »
It seems, now, that cmd.exe works but it doesn't take any input.

pull down the latest trunk and try again. should work again (but not in all cases).

let me reiterate that this plugin doesn't support full blown terminal emulation. I'd like it to, but am not sure I have time/inclination/ability.

I saw a pretty cool thread demonstrating how to embed the windows cmd.exe app as a window in another app. I'm sure similar could be achieved on linux. This begins to encroach on window manager territory...

Offline igorevc

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: Plugin for a Programming Language
« Reply #27 on: June 11, 2009, 01:51:30 pm »
Good day to everyone.

I'm having a problem with my plugin.

My operating system is Windows XP SP3.
My compiler is MinGW 5.1.4.
First I updated wxWidgets to 2.8.10 (official) and compiled it.
Then, I updated the Code::Blocks source files (through SVN) and compiled Code::Blocks.
Next, I copied wxmsw28u_gcc_custom.dll to devel and ran update.bat.

Finally, within the fresh Code::Blocks build, I rebuild my plugin and tried to install. The problem is the following message:

C:\Aplications\CodeBlocks\src\output/share/codeblocks/plugins/myplugin.dll: not loaded (missing symbols?)

What must I do to resolve this problem?

Thank you for your attention.
« Last Edit: June 11, 2009, 01:54:46 pm by igorevc »

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2802
Re: Plugin for a Programming Language
« Reply #28 on: June 11, 2009, 02:02:46 pm »
Good day to everyone.

I'm having a problem with my plugin.

My operating system is Windows XP SP3.
My compiler is MinGW 5.1.4.
First I updated wxWidgets to 2.8.10 (official) and compiled it.
Then, I updated the Code::Blocks source files (through SVN) and compiled Code::Blocks.
Next, I copied wxmsw28u_gcc_custom.dll to devel and ran update.bat.

Finally, within the fresh Code::Blocks build, I rebuild my plugin and tried to install. The problem is the following message:

C:\Aplications\CodeBlocks\src\output/share/codeblocks/plugins/myplugin.dll: not loaded (missing symbols?)

What must I do to resolve this problem?

Thank you for your attention.


One way is to change the app.cpp line:

"wxLog::EnableLogging(false);" to true , then recompile CB.

An error box will pop up  when your plugin is loaded containing the  missing symbol.


Offline igorevc

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: Plugin for a Programming Language
« Reply #29 on: June 11, 2009, 06:29:29 pm »
Good afternoon.

I did change wxLog::EnableLogging(false);" to true.
I tried to install again the plugin and shows a dialog with the error.

The error says that "it is impossible to locate the specified module".

I hope it helps to unravel the solution for this problem.

Thank you for your attention.

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2802
Re: Plugin for a Programming Language
« Reply #30 on: June 12, 2009, 02:15:51 pm »
Good afternoon.

I did change wxLog::EnableLogging(false);" to true.
I tried to install again the plugin and shows a dialog with the error.

The error says that "it is impossible to locate the specified module".

I hope it helps to unravel the solution for this problem.

Thank you for your attention.

Is it possible that you have more than one wxmsw28u_gcc_custom.dll on your system. You might be loadng the wrong one when CB executes ?

Offline igorevc

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: Plugin for a Programming Language
« Reply #31 on: July 09, 2009, 12:42:20 pm »
Good day to all.
I'm sorry, pecan, for not replying your answer because I was busy building the plugin. In the meantime, I have solved the problem.

I have finished the plugin, through Code::Blocks SVN, but I need help to port to the nightly builds.
The plugin was developed in Windows with wxPack (an already compiled wxWidgets 2.8.9) and on Windows XP.
And the plugin was also compiled and used with success on Ubuntu.
I tried to port the code to the most recent nightly build for Windows, but it gives the error od different SDK version.

Thank you for your attention.

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576