User forums > Using Code::Blocks

Open multiple files in Code::Blocks from the command line

(1/2) > >>

Immint:
I'm very used to being able to easily open files from the command line in my favourite editor, and for multiple reasons this habit has become ingrained in my workflow. I'd like to be able to do this with Code::Blocks as well, but I'm running headfirst into a brick wall here. :-\

The help page for the executable offers the --file= command line option, but this only allows you to provide a single file. When adding the command line option twice, only the last file is opened. I could write a batch script to take all my command line arguments and run the codeblocks.exe executable for each separately. This works like a charm IFF Code::Blocks is already running. If a new instance has to be started, only the first file is opened... ???

Second, I noticed you can add multiple files on the commandline without --file=. This resulted in a very odd problem. If I open a file like this, then close it (the file; not Code::Blocks), then open another file, both files now get opened. If I close the two files and open a third file like this, Code::Blocks opens all three previously thusly-opened files! :o The only way to get Code::Blocks to forget about the files opened this way appears to be to completely close the program. Clearly this is not what I want either. :(

To add insult to injury, the Windows Explorer has no trouble doing what I want at all. Click single files, multiple files, it'll always open them correctly without re-opening previously opened files. Of course, in Windows 10, it seems entirely impossible to verify how the Explorer communicates with the programs it launches (or at least the option is very well hidden), so this doesn't help me at all. >:(

So to reiterate, here is the question:
How do I correctly open multiple files in Code::Blocks from the command line?

Thanks! :)

BlueHazzard:
i am curious about your workflow... Are you using c::b as generic text editor? Or why do you want to open multiple source files without a project?

Immint:
I do actually plan to use Code::Blocks as a generic text editor as well if it lets me (I already have it open and it's good at editing code; why not? :P) but the main reason I want to open files from the command line is because I use the command line to find the files I want to open in the first place, for example based on the diff between two git commits or a grep of the source tree, or because a ticket already includes a list of relevant files. This is true even when I'm working on a Code::Blocks project.

There are also many cases where I'm working on code that's not (only) mine, where I don't want to pollute my repository with a Code::Blocks project (which I then have to keep up to date if source files are added or removed by someone else that doesn't use Code::Blocks), or a project that's better compiled by makefiles, even if just because one already exists and I don't have the time to make a working .cbp file out of it, and I definitely don't want to maintain both a makefile and a Code::Blocks project file.

Anyway, that's all off-topic. I'd still like to have an answer to the question! :)

oBFusCATed:
Probably no one has tried it or used it in such a way. Patches welcome.
There were some other reports of this being broken, but I don't remember details. :(


--- Quote from: Immint on October 05, 2016, 01:43:24 am ---To add insult to injury, the Windows Explorer has no trouble doing what I want at all. Click single files, multiple files, it'll always open them correctly without re-opening previously opened files. Of course, in Windows 10, it seems entirely impossible to verify how the Explorer communicates with the programs it launches (or at least the option is very well hidden), so this doesn't help me at all. >:(

--- End quote ---
I think it works using DDE https://msdn.microsoft.com/en-us/library/windows/desktop/ms632538(v=vs.85).aspx

p.s. cb supports makefile based projects...

Jenna:
I can confirm this.
C::B has a a list of files to be opened delayed.
My guess is, that the files are not removed from this loist, if they are opened.
I try to look into it.


--- Quote from: oBFusCATed on October 06, 2016, 01:19:56 am ---I think it works using DDE https://msdn.microsoft.com/en-us/library/windows/desktop/ms632538(v=vs.85).aspx

--- End quote ---
and ipc on Linux, but he mechanism is (more or less) transparent inside C::B, because we use the wxWidgets implementation.

Navigation

[0] Message Index

[#] Next page

Go to full version