Author Topic: Edit project as regular text file in editor plug-in  (Read 18266 times)

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5490
Edit project as regular text file in editor plug-in
« on: November 08, 2005, 10:16:47 pm »
Dear all,

I have developed a plug-in which allows you to open the project file in an editor pane, so you can view (and edit) it as the xml file it actually is.

The plug-in now foresees in 2 choices :
   - edit the project file
   - reload the project file (closing and opening it : mgiht ask to save in between if after modification it has not been saved yet)

The functionality can be accessed through :
  - the project menu (2 new entries : open project for edit , reload project)
  - right clicking on the project name in the project manager pane (2 new entries : open project for edit , reload project)

Install it by copying the ddl in the attached zip file into the CB plug-ins directory. The zip file also contains the cbp project and the sources. It has been developed and tested on Windows XP, so you might need to change the cbp to your setup accordingly.

Enjoy it,
kind regards,
Lieven

PS : I do have some requests for the core developers, here's my story.

When a file has been modified outside Code::Blocks, CB offers to reload it. This works for source files open in a editor pane, but this is not the case for the project file itself.

This plug-in I developed allows you to open the project file in an editor pane, so you can view (and edit) it as the xml file it actually is. After you edit the xml file, CB has no idea that the project file has to changed. It would be nice that CB also check this, so it can be automatically reloaded.

The plug-in now foresees in 2 choices :
   - edit the project file
   - reload the project file (closing and opening it : might ask to save in between if after modification it has not been saved yet)


So I have some questions :
   - Can the core CB developers adjust the code base so CB also checks for external modifications of the project file and offer to reload it as with source files ?
   - if the answer is no, could they pinpoint me the code that does the reloading of the source files, so I could change/adopt it myself  (I prefer a yes on the first quesion ;-) )?



[attachment deleted by admin]
« Last Edit: November 08, 2005, 10:18:21 pm by killerbot »

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Edit project as regular text file in editor plug-in
« Reply #1 on: November 08, 2005, 10:47:48 pm »
*shudders*
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Edit project as regular text file in editor plug-in
« Reply #2 on: November 08, 2005, 10:59:17 pm »
Thomas: What was that *shudder* for?

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Edit project as regular text file in editor plug-in
« Reply #3 on: November 08, 2005, 11:01:26 pm »
For editing config files by hand while the program is running. Things like that make me shudder.  :P
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Edit project as regular text file in editor plug-in
« Reply #4 on: November 08, 2005, 11:20:21 pm »
Oh, I see. Anywyay, what do you think of editing the checkforexternallymodifiedfiles function?

I find that a valid point, since sometimes i update from CVS but the project isn't reloaded.

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: Edit project as regular text file in editor plug-in
« Reply #5 on: November 08, 2005, 11:32:43 pm »
Oh, I see. Anywyay, what do you think of editing the checkforexternallymodifiedfiles function?

I find that a valid point, since sometimes i update from CVS but the project isn't reloaded.

The only bulletproof way of correctly reloading the project is to close and reopen it. Anything else and a million bugs are waiting to happen...
Be patient!
This bug will be fixed soon...

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Edit project as regular text file in editor plug-in
« Reply #6 on: November 08, 2005, 11:35:43 pm »
Hmm, personally I am not enthousiastic about that, it's major overkill CPU-wise.

Reloading an editor may take 0.1 seconds, but loading a project can be 5 seconds, too, including parser.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Edit project as regular text file in editor plug-in
« Reply #7 on: November 09, 2005, 02:59:14 am »
I see. But what happens if the project is modified externally, and THEN I add a file? The external changes would be lost. And personally I don't have anything against closing and reopening the project.

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5490
Re: Edit project as regular text file in editor plug-in
« Reply #8 on: November 09, 2005, 06:01:32 am »
That's the way I also implemented it, closing and reopening. Suppose automated checking on changes of the project file would happen, reloading can be just closing and reopening.
If you edit in the editor of cb, it should work rather well. If you 'GUI' changed something to the project and in the mean time you also changed the xml file for example in another editor (gedit, notepad, ..) then you are in for trouble. Because one save can overrule the other save, but this problem is also present for regular source files.

The reason I made this plug-in is, when your project (for example a library) has many targets (for example debug/release builds with different compilers for maybe different platforms); then I might be way easier to make an adjustment (say needed for 'nearly' all targets) if you could do that in the text xml file, instead of wading through all those gui panels.
Gui's are nice and user friendly but sometimes one needs more 'core?/hacking?' power.

Example :the project generated by the plug-in generator plug-in contain incorrect paths for compiler and linker (see another post by me). Each time I generated the plug-in starters I could adjust everything through the gui's. But I could just copy the correct stuff from a correct cbp xml file and copy it in the new wrongly generated cbp. Ok, fair is fair, if that bug is fixed, this example is no longer, but other occasions might benefit from this approach.

Another occasion where at minimum the reload command can be of use, is when you use versioning control system, and you retrieve from the system an older or newer version and CB had the project still open. So then my plgu-in comes to the rescue (you could close CB before you update the stuff from the version control system), it is automated then, or semi-automated since the user still issues to reload command. But it might be nice if CB detects the change and offers you the reload, the user then should decide what to do, if he had already made an unsaved change to the project and now he wants yet another different version of that project.

Hey, these are my pros, no doubt there are good arguments for the cons.



Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5490
Re: Edit project as regular text file in editor plug-in
« Reply #9 on: November 09, 2005, 06:07:35 am »
one more addition.
I do agree on the cpu penalty, but as like in my example (version control retrieval) you need to reload anyway.
If you just add a compiler switch in the gui way of working I guess there's no reloading and no parsing needed. If you close and open, this does happen, so in this case you suffer the penalty. But this might be still quicker then GUI travelling through all the spots where you want to change stuff (considering it is not just a single trivial change).

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Edit project as regular text file in editor plug-in
« Reply #10 on: November 09, 2005, 09:57:44 am »
The reason I made this plug-in is, when your project (for example a library) has many targets [...]
Each time I generated the plug-in starters I could adjust everything through the gui's. But I could just copy the correct stuff from a correct cbp xml file and copy it in the new wrongly generated cbp. [...]
I agree. It's the same for me. I often create a new project on the basis of an old one. I also edit the XML file directly, e.g. to add/rename certain files or add another target without using the GUI. That's often a simple copy&paste operation (thanks XML!). So this plugin will be helpful for me. Thanks!

Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5490
Re: Edit project as regular text file in editor plug-in
« Reply #11 on: December 17, 2005, 06:43:48 pm »
Updated project, minor code change, warning removed, and build for svn head revision.

Lieven

[attachment deleted by admin]

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5490
Re: Edit project as regular text file in editor plug-in
« Reply #12 on: February 13, 2006, 03:59:54 pm »
updated to todays revision (plug in name switch, sort of ...)

[attachment deleted by admin]

Offline LETARTARE

  • Lives here!
  • ****
  • Posts: 531
  • L'ami de l'homme.The friend of man.
    • LETARTARE
Re: Edit project as regular text file in editor plug-in
« Reply #13 on: June 03, 2017, 06:21:34 pm »
Hello,
where can I download the plugin ?
Thank you
CB-13483, plugins-sdk-2.25.0 : Collector-2.0.0, AddOnForQt-3.9.1
1-Win7 Business Pack1 64bits : wx-3.2.4, gcc-8.1.0,
2-OpenSuse::Leap-15.4-64bits : wx-3.2.4;gtk3, gcc-8.2.1,
=> !! The messages are translated by Deepl