Author Topic: CodeBlocks Scripting  (Read 3228 times)

Offline JATothrim

  • Single posting newcomer
  • *
  • Posts: 5
CodeBlocks Scripting
« on: October 14, 2011, 01:53:17 am »
Hey!

I was completly suprised that the IDE included a complete scripting language after using it more than two years. :lol:
I was wondering how I could execute a script when the Code::Blocks IDE quits? Executing script on startup is clear as it's documented on manuals.
I'm planing to use ImDisk to mount RAM Disk when the IDE starts. But as i said, I need to backup the disk contents and unmount the volume when the IDE quits.
I'm not asking how to use the ImDisk tool, but rather help for writing plugin script for the IDE to use the tool. C++ goes okay but squirrel doesn't.  :(

Editor commands...
Scriptplugin template:
Code: [Select]
class RAMDiskMount extends cbScriptPlugin
{
    // mandatory to setup the plugin's info
constructor()
{
info.name = _T("Mount RAM DISK");
info.title = _T("Mount RAM DISK");
::Log(_T("Mounted 512MiB RAM DISK"));
}

    // how do I run something on "unregisterplugin"?

   
}

// this call actually registers the script plugin with Code::Blocks
RegisterPlugin(RAMDiskMount());

Btw. compiling using ramdisk is ridiculously fast.  :wink:
PS: sorry for typos, I'm not perfect on english.
-Registeration Captcha is funny. : D

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12020
    • Travis build status
Re: CodeBlocks Scripting
« Reply #1 on: October 14, 2011, 02:13:43 am »
You have to handle the cbEVT_APP_START_SHUTDOWN,
but there is not script binding for it, so you'll have to modify C::B and then provide a patch we can apply.
Here you'll find some docs about script binding: http://wiki.codeblocks.org/index.php?title=Script_bindings

Another option is to make a shutdown.script, which is executed in MainFrame::OnApplicationClose or something more suitable.
This is the simpler approach and it will make the starting/shutdown symmetric...

(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9496
Re: CodeBlocks Scripting
« Reply #2 on: October 14, 2011, 09:32:54 am »
You have to handle the cbEVT_APP_START_SHUTDOWN,
but there is not script binding for it, so you'll have to modify C::B and then provide a patch we can apply.
That is true. And don't worry, a patch shouldn't be too hard, there are plenty of examples. Are you willing to try?
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline JATothrim

  • Single posting newcomer
  • *
  • Posts: 5
Re: CodeBlocks Scripting
« Reply #3 on: October 15, 2011, 02:09:04 am »
Thank you for the info. I'll probaly just add menu item to unmount the disk and mount the disk at IDE start up - no time to start developing developer tools.  :)
I did succeed to compile the C::B from source on linux, but it was pain. Plus I got it crashing when I pasted some rare unicode chatters to the editor. (on purpose)

One problem is that the ImDisk also requires pure admin powers to be able to load a kernel driver on fly. :D