Author Topic: command line to tell a running Code::Blocks to open a file  (Read 7667 times)

Offline DrewBoo

  • Multiple posting newcomer
  • *
  • Posts: 110
command line to tell a running Code::Blocks to open a file
« on: December 09, 2008, 10:11:44 pm »
I'm in Unix-land, and often find myself at the command line using my terminal application of choice.

Is there a way to tell the Code::Blocks instance which I am already running to open a particular file?

Using "codeblocks --file=MyFile" always opens up a new Code::Blocks (or, based on my settings, tells me it can't open a new Code::Blocks and aborts)



DrewBoo


mariocup

  • Guest
Re: command line to tell a running Code::Blocks to open a file
« Reply #1 on: December 09, 2008, 11:45:54 pm »
Hi DrewBoo,

under windows it is already possible using the DDE command. Under Linux this feature is currently disabled, but it think it could be added in app.cpp. wxWidgets provides IPC communications with a special class that is using under the hood either real windows IPC or TCP on other platforms.

Bye,

Mario

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: command line to tell a running Code::Blocks to open a file
« Reply #2 on: December 10, 2008, 12:56:36 am »
On my debian-system, I just added a wxClient-class to C::B (with #ifndef __wxMSW__) and reused the most part of the actual DDEServer for MSW to open a file inside a running C::B-process.

For test-purposes I hardcoded the filename, and it worked as expected.

If it will be implemented the question is, how should it work ?

Shall it always try to open a given file in a running instance of C::B, or only if multiple instances are not allowed, or should another instance of C::B only be opened if no filename is given on commandline, or ...

I hope I found some more time this week and maybe this weekend to work on it a little more.

Offline DrewBoo

  • Multiple posting newcomer
  • *
  • Posts: 110
Re: command line to tell a running Code::Blocks to open a file
« Reply #3 on: December 10, 2008, 05:28:28 pm »
If it will be implemented the question is, how should it work ?

Shall it always try to open a given file in a running instance of C::B, or only if multiple instances are not allowed, or should another instance of C::B only be opened if no filename is given on commandline, or ...

You bring up good questions.

It would certainly be safest to implement this specifically for "no multiple instances" mode.  That is, no user could reasonably be jostled by this change.

Then again, if Code::Blocks already has similar behavior in Windows, the best design is to match that behavior.