Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Plugins development => Topic started by: frankmail007 on June 20, 2006, 05:51:44 pm

Title: Code snippet plugin
Post by: frankmail007 on June 20, 2006, 05:51:44 pm
Have you ever used wxCRP or Code snippet management in VC Express 2005? I think a Code Snippet Plugin will be a good feature for CodeBlocks. It should have the following features:

1. Code Snippet management
2. Save as a template which can be used by new project.

What do you think?
Title: Re: Code snippet plugin
Post by: Game_Ender on June 20, 2006, 07:44:00 pm
How about a real description of number 1.  We don't all use VS 2005.  There are several dozen other platforms and many IDEs out there.

EDIT: I exaggerated, if I had to take a rough guess I would say there are about a dozen other major platforms out there.
Title: Re: Code snippet plugin
Post by: David Perfors on June 20, 2006, 07:47:14 pm
good idea ;) saves a lot of time searching the right peace of code...
Title: Re: Code snippet plugin
Post by: kidmosey on July 22, 2006, 03:48:49 am
Essentially, wxCRP (http://www.xs4all.nl/~jorgb/wxcrp/) is a repository (searchable) for all of your code/files that you think you will reuse.

You might be able to use C::B's project templates for this... although that might be overkill for smaller code snippets.

Personally, I just use a snippet directory for all of my reusable code.  Seems to work just as well.
Title: Re: Code snippet plugin
Post by: Pecan on July 22, 2006, 04:58:49 am
Essentially, wxCRP (http://www.xs4all.nl/~jorgb/wxcrp/) is a repository (searchable) for all of your code/files that you think you will reuse.

You might be able to use C::B's project templates for this... although that might be overkill for smaller code snippets.

Personally, I just use a snippet directory for all of my reusable code.  Seems to work just as well.


wxCRP does not appear to be cross-platform capable. The author's last update indicates he was working on a linux port, and there is no mention of Mac support.

The last update was 2 1/2 yrs ago and no source is available. So I don't think it's possible to adapt for CodeBlocks.

Title: Re: Code snippet plugin
Post by: mdelfede on July 22, 2006, 12:57:25 pm

wxCRP does not appear to be cross-platform capable. The author's last update indicates he was working on a linux port, and there is no mention of Mac support.

The last update was 2 1/2 yrs ago and no source is available. So I don't think it's possible to adapt for CodeBlocks.



The source is indeed available through cvs.

Ciao

Max
Title: Re: Code snippet plugin
Post by: Pecan on July 22, 2006, 02:00:24 pm

The source is indeed available through cvs.

Ciao

Max


Thanks, that escaped me for the moment. I was looking in the files section and it was late at night. I'll have a "look see".
Title: Re: Code snippet plugin
Post by: mdelfede on July 22, 2006, 02:20:31 pm

Thanks, that escaped me for the moment. I was looking in the files section and it was late at night. I'll have a "look see".

Yes, it took me a while to fnd it, too  :)
It seems be using wxwidgets 2.4....
Title: Re: Code snippet plugin
Post by: artoj on August 08, 2006, 10:07:17 pm
Well, I decided to create a Code Snippets plugin and it's almost ready.

Things that I'm proud of:
- Custom artwork by me (I like green :( )
- Unoptimized find-as-you-type search
- It integrates with C::B (creates a docking window)
- It's simple

There are some things that I must do before I release it tough, e.g. testing on Linux and some code cleanup.

Screenshot:

(http://ajonsson.kapsi.fi/images/codesnippets.png)
Title: Re: Code snippet plugin
Post by: sethjackson on August 08, 2006, 10:20:27 pm
Well, I decided to create a Code Snippets plugin and it's almost ready.

Things that I'm proud of:
- Custom artwork by me (I like green :( )
- Unoptimized find-as-you-type search
- It integrates with C::B (creates a docking window)
- It's simple

There are some things that I must do before I release it tough, e.g. testing on Linux and some code cleanup.

Sweet. :D
Title: Re: Code snippet plugin
Post by: Game_Ender on August 08, 2006, 10:21:38 pm
Very cool, does it have multiple language support?

On a side note, I think it clutters a thread when people quote posts that have long code segments or imags inlined.
Title: Re: Code snippet plugin
Post by: kidmosey on August 09, 2006, 04:52:41 am
Well, I decided to create a Code Snippets plugin and it's almost ready.

Things that I'm proud of:
- Custom artwork by me (I like green :( )
- Unoptimized find-as-you-type search
- It integrates with C::B (creates a docking window)
- It's simple

There are some things that I must do before I release it tough, e.g. testing on Linux and some code cleanup.

Can't wait to try it out... resembles my present "directory" method, except it's integrated! :D

btw, how are snippets stored?
Title: Re: Code snippet plugin
Post by: killerbot on August 09, 2006, 09:26:44 am
sounds nice, me too : impatient to try it out ;-)
Title: Re: Code snippet plugin
Post by: Vampyre_Dark on August 09, 2006, 09:29:54 am
Things that I'm proud of:
- Custom artwork by me (I like green :( )
- Unoptimized find-as-you-type search
- It integrates with C::B (creates a docking window)
- It's simple
But does it do Tetris?

Very interested in this. Also want to know how the snippets are stored. I think they should be easily retriveable without going through the plugin, so they can be easily backed up, or used elsewhere without C::B
Title: Re: Code snippet plugin
Post by: artoj on August 09, 2006, 10:31:46 am
Very cool, does it have multiple language support?

If you create C/C++, Python, Ruby etc. category you have multiple languages support I guess. The number of subcategories is not limited or atleast it's not limited in my code.

btw, how are snippets stored?

Currently they're in the main Code::Blocks' configuration file because it was the easiest to implement. However, creating export/import to xml would be easy, though I'm not planning it to the first release.

But does it do Tetris?
Actually, I'm thinking more about Quake III, it's GPL so why not 8)

Quote
Very interested in this. Also want to know how the snippets are stored. I think they should be easily retriveable without going through the plugin, so they can be easily backed up, or used elsewhere without C::B

If you backup the Code::Blocks' config file the snippets are backed up too, though, a more separate solution would be indeed better. I guess the XML import/export would be the best solution.
Title: Re: Code snippet plugin
Post by: artoj on August 14, 2006, 02:35:11 pm
OK, first public version is now ready and you can download it from here: http://ajonsson.kapsi.fi/files/codesnippets.zip (http://ajonsson.kapsi.fi/files/codesnippets.zip).

It uses external XML file called codesnippets.xml to save the snippets. This file is saved to Code::Blocks' config directory.

Now, the most important thing, I'm unable to build this plugin on Windows. The reason is beoynd my knowledge. You can read the issue from this topic: http://forums.codeblocks.org/index.php?topic=3804.0 (http://forums.codeblocks.org/index.php?topic=3804.0). *nix building works fine.

The zip file has a readme in it, it should answer most of your questions.
Title: Re: Code snippet plugin
Post by: MortenMacFly on August 14, 2006, 03:30:30 pm
Now, the most important thing, I'm unable to build this plugin on Windows.
Nice work! And I can tell you: I can compile this nicely under Windows. However, I had to make some adjustments to the project file. Please find my variant attached to this post for your inspection. I'm not sure if this will fix your issue, too - but it's worth a try... ;-)

[attachment deleted by admin]
Title: Re: Code snippet plugin
Post by: killerbot on August 14, 2006, 03:35:15 pm
I could build it too, first had some linker ?warnings?
with Morton's adjustment (place the plug-in in a subdir of the contrib dir !!), those warnings are gone , this is my output (the update.bat is not present yet, therefor the little error at the end) :
Quote
-------------- Build: Debug - Win32 in Code Snippets Plugin ---------------
Compiling: codesnippetstreectrl.cpp
Compiling: codesnippetswindow.cpp
Compiling: snippetitemdata.cpp
Compiling: codesnippets.cpp
In file included from codesnippetswindow.h:24,
                 from codesnippets.cpp:32:
C:/Projects/wxWidgets-2.6.3/include/wx/dnd.h:53: warning: inline function `bool wxIsDragResultOk(wxDragResult)' declared as dllimport: attribute ignored
Linking dynamic library: ..\..\..\devel\share\CodeBlocks\plugins\codesnippets.dll
Running project post-build steps
update.bat
Execution of 'update.bat' in 'C:\Projects\CodeBlocks\src\plugins\contrib\codesnippets' failed.
Nothing to be done.
Title: Re: Code snippet plugin
Post by: MortenMacFly on August 14, 2006, 03:42:50 pm
Execution of 'update.bat' in 'C:\Projects\CodeBlocks\src\plugins\contrib\codesnippets' failed.
Nothing to be done.
Ah yes - I've forgotten this. I've added a batch file that copies the images for me, here is the content of update.bat (to be placed in the plugin's directory):
Code
@echo off
cls
md ..\..\..\devel\share\CodeBlocks\images\codesnippets > nul 2>&1
md ..\..\..\output\share\CodeBlocks\images\codesnippets > nul 2>&1
copy resources\*.png ..\..\..\devel\share\CodeBlocks\images\codesnippets\ > nul 2>&1
copy resources\*.png ..\..\..\output\share\CodeBlocks\images\codesnippets\ > nul 2>&1
BTW: What I've also done is the re-order how the libs are linked to the plugin and (!) to add the tixml lib into linkage. Thus the warnings were gone and everything is fine.
With regards, Morten.
Title: Re: Code snippet plugin
Post by: killerbot on August 14, 2006, 03:45:10 pm
Both Morton and I have put the plug-in in our source tree at the level on contributed plug-ins. Hint hint ;-)

Title: Re: Code snippet plugin
Post by: artoj on August 14, 2006, 03:57:58 pm
Both Morton and I have put the plug-in in our source tree at the level on contributed plug-ins. Hint hint ;-)

You can add it to the trunk, if you really want to :)
Title: Re: Code snippet plugin
Post by: killerbot on August 14, 2006, 04:06:21 pm
If I get the approval of the Don, I will add it tomorrow ;-)
Title: Re: Code snippet plugin
Post by: Pecan on August 14, 2006, 10:01:00 pm
Import from file... is appending the file to the current tree.

Is there a way to clear the previous xml file/tree before importing?

I'd rather not keep all the snippets in memory at the same time. If Import from file.. would clear the tree then we could separate large snippets into individual xml files and load only when needed.
 
Title: Re: Code snippet plugin
Post by: MortenMacFly on August 15, 2006, 07:24:32 am
Is there a way to clear the previous xml file/tree before importing?
Nice would be a question like: Press "Append" to append the file or "New" to import. (Click "Cancel" to abort.). I think both can be interesting: To append to an existing code snippet list or to "create" a new one when importing. Oh - and by the way: I truly vote for adding this to SVN. It's great!
Title: Re: Code snippet plugin
Post by: artoj on August 15, 2006, 10:10:38 am
The import / export functionality doesn't actually make sense anymore because it's same type of file that gets saved and loaded. In the first version the snippets were saved to the main C::B config file so that's why the Import / Export.

The import/export should be changed to "Load from file" and "Save to file" or something like that. I think another menu item "Load from file (append)" should added too + "remove all".
Title: Re: Code snippet plugin
Post by: killerbot on August 15, 2006, 12:17:27 pm
I'll add it to svn this afternoon ...
Title: Re: Code snippet plugin
Post by: Pecan on August 15, 2006, 02:29:56 pm
Once this is under SVN, If you are accepting patches, I'd like to offer the following which I've already coded in another app. It might save you some time, and avoid duplicated effort.

* clipboard copy/paste to/from tree  via toolbar (I'll adapt it to your code)

* drag/drop/copy/paste multiple formats (ie filename or text format) useful to record workspace/project/filenames when they run off the "recent" list; the user just drags/copies the workspace/project/file name into the management window and it opens as if it had been on the recent list.

* drag/drop text from/to external apps (scite and StEdit are very useful).

thanks for this nice plugin,
pecan
Title: Re: Code snippet plugin
Post by: artoj on August 15, 2006, 02:58:52 pm
Once this is under SVN, If you are accepting patches, I'd like to offer the following which I've already coded in another app. It might save you some time, and avoid duplicated effort.

Sure, thanks :)

Quote
* drag/drop text from/to external apps (scite and StEdit are very useful).

You do this already but you can't drag and drop to external apps. The problem is that I want to able to drag and drop within the tree also, I don't know how this and the drag and drop to external apps can be archieved (or more importantly, will it work).
Title: Re: Code snippet plugin
Post by: Pecan on August 15, 2006, 03:46:02 pm
Quote
The problem is that I want to able to drag and drop within the tree also, I don't know how this and the drag and drop to external apps can be archieved (or more importantly, will it work).

Yes, it works, I already have the code.

I've also seen code that allows drag/drop within the tree by creating an xml doc of the selected source and children then inserting it in the target position. It allowed copy/moving an item up/down and in/out.

It copied the source xml to the clipboard, then inserted at the drop target.
I can't seem to find it now, but I'll keep looking. If I don't find it, and you don't get to it first, I'll try to recreate it from memory.

I also meant to say that I already had code that dragged/dropped from/to copy/pasted to/from external apps from a wxTreeCtrl. It uses another xml other than tinyXml, but it can be adapted.

I see that codesnippet can drag text "into" the tree item from an external app, but not "out" of the tree. Thats where the clipboard/dragdrop code that I have already written comes in. I'll rework it for CodeSnippets.

It would also be nice to see a "peek" of the snippet when the tree item is selected. (This is either a feature request or a "pecan todo" if you dont have time.)
Title: Re: Code snippet plugin
Post by: artoj on August 15, 2006, 04:42:43 pm
Yes, it works, I already have the code.

I've also seen code that allows drag/drop within the tree by creating an xml doc of the selected source and children then inserting it in the target position. It allowed copy/moving an item up/down and in/out.

It copied the source xml to the clipboard, then inserted at the drop target.
I can't seem to find it now, but I'll keep looking. If I don't find it, and you don't get to it first, I'll try to recreate it from memory.

Wow, that's really cool way to do it, I never tought of that. :shock:

Quote
I also meant to say that I already had code that dragged/dropped from/to copy/pasted to/from external apps from a wxTreeCtrl. It uses another xml other than tinyXml, but it can be adapted.

I see that codesnippet can drag text "into" the tree item from an external app, but not "out" of the tree. Thats where the clipboard/dragdrop code that I have already written comes in. I'll rework it for CodeSnippets.

OK, thanks, but could you wait untill I get my first patch integrated in to the source tree. Some of the code needs to moved, mainly the XML saving etc. to the main tree ctrl subclass. Currently the code is floating in the CodeSnippetsWindow class.

Quote
It would also be nice to see a "peek" of the snippet when the tree item is selected. (This is either a feature request or a "pecan todo" if you dont have time.)

Yes, I agree, killerbot mentioned about this too. I thinked about tooltips first but after reading the wxWidgets docs it seems that they are only supported on Windows (or I'm reading the docs incorrectly). Another way would be to add some text control under the tree control, while I am not fundamentally against this, I don't think this is a good solution.
Title: Re: Code snippet plugin
Post by: Pecan on August 15, 2006, 05:32:44 pm
OK, thanks, but could you wait untill I get my first patch integrated in to the source tree. Some of the code needs to moved, mainly the XML saving etc. to the main tree ctrl subclass. Currently the code is floating in the CodeSnippetsWindow class.

Of course. I'm not being pushy I hope.

Quote
It would also be nice to see a "peek" of the snippet when the tree item is selected. (This is either a feature request or a "pecan todo" if you dont have time.)

Yes, I agree, killerbot mentioned about this too. I thinked about tooltips first but after reading the wxWidgets docs it seems that they are only supported on Windows (or I'm reading the docs incorrectly). Another way would be to add some text control under the tree control, while I am not fundamentally against this, I don't think this is a good solution.

You might want to look at a "timed" wxMiniFrame. Something like a CB popUpWindow as used in infoWindow.cpp, but using a miniFram. It's cross-platform and the CB code is practically clonable.

Title: Re: Code snippet plugin
Post by: Pecan on September 16, 2006, 11:03:22 pm
Arto,

Included in the attached file (see URL below) is a standalone version of your CodeSnippets plugin.

I've included the code I promised except for the internal drag/dropping of tree item. I tried it, but the sort just put 'em back in place. I'll work on that though.

I've include the following features:

Please see the Help->About text for additional information.

You are welcome to use any of the code that you find to be a good addition to CodeSnippets.
You might find the program as a useful utility to prototype additions to the CodeSnippet plugin. It's so much easier to debug.

(http://img220.imageshack.us/img220/8500/sniplistpropmr9.png)

(http://img209.imageshack.us/img209/6610/sniplisthelpdi2.png)

SnipList011.zip
http://savefile.com/files/77784 (http://savefile.com/files/77784)

Direct download
http://dl1u.savefile.com/52c868ef5691ba18226eb86bbd4f9147-4af2299f6f5f8bed86bf10f1b2f39cb0/SnipList011.zip (http://dl1u.savefile.com/52c868ef5691ba18226eb86bbd4f9147-4af2299f6f5f8bed86bf10f1b2f39cb0/SnipList011.zip)

Thank you for such a nice plugin.

pecan
Title: Re: Code snippet plugin
Post by: artoj on September 17, 2006, 11:13:24 am
Thank you very much Pecan! :)

I'll try to integrate the features to the next version of Code Snippets.

I've created a patch which I mentioned earlier; it cleans up the code / UI.

Changes:

Code

* Added visual feedback to the searchbox: if no items can be found, the
   background is painted light red and the root item is selected

* Changed menu functionality / structure:

      - "Import from file" is now called "Load from file", it first
         deletes all the current items and then loads the file

      - "Export to XML" is now called "Save to file", with no
         functionality changed

      - To append items from file, hold down Shift while right clicking the root item,
         you should then see a "Load from file (append)" item in the menu

      - Added "Remove all" menu item

* Removed some parts of the documentation which are now obsolete

* Some code refactoring

* Removed some of the debug messages


The append menu system might change in the future; however I don't like to stack the pop up menu full of items.

Full source (http://ajonsson.kapsi.fi/files/codesnippets-src.zip)

Patch (http://ajonsson.kapsi.fi/files/codesnippets-patch.patch) (against latest SVN version)

Title: Re: Code snippet plugin
Post by: Pecan on September 17, 2006, 02:54:52 pm

I'll try to integrate the features to the next version of Code Snippets.

I've created a patch which I mentioned earlier; it cleans up the code the UI.
...<snip>...

Full source (http://ajonsson.kapsi.fi/files/codesnippets-src.zip)

Patch (http://ajonsson.kapsi.fi/files/codesnippets-patch.patch) (against latest SVN version)


Arto,

You should be able to apply your patches directly to the CodeBlocks svn sources at berlios.

If he hasn't already, in a Personal Message, ask Mandrav for permission to update your own sources.
Title: Re: Code snippet plugin
Post by: szczepan on September 21, 2006, 10:20:02 pm
I don't seem to be able to figure out how to actually edit code snippets. When I right-click on a snippet node there are only two menu items, "Apply" and "Remove".

Is editing the XML file really the only way?

Does this plugin do variable substitutions? If so, what is the markup for a variable placeholder in snippet body?

Thanks in advance
Title: Re: Code snippet plugin
Post by: dmoore on September 21, 2006, 10:36:09 pm
Quote
I don't seem to be able to figure out how to actually edit code snippets. When I right-click on a snippet node there are only two menu items, "Apply" and "Remove"

couldn't you just insert the snippet into the editor by double clicking, edit the text, then select and drag the text back into your snippet?
Title: Re: Code snippet plugin
Post by: artoj on September 22, 2006, 09:36:45 am
Does this plugin do variable substitutions?

No, it's in the TODO list.
Title: Re: Code snippet plugin
Post by: szczepan on September 22, 2006, 04:31:09 pm
Does this plugin do variable substitutions?

No, it's in the TODO list.

OK. Perhaps you could reuse the built-in abbreviations code?
Title: Re: Code snippet plugin
Post by: artoj on September 22, 2006, 04:52:13 pm
OK. Perhaps you could reuse the built-in abbreviations code?

Yeah, I was actually browsing the abbreviations code.

However I will implement the editing of the snippets first which probably requires writing the configuration dialog so it might take a while.
Title: Re: Code snippet plugin
Post by: Pecan on September 22, 2006, 07:32:12 pm
OK. Perhaps you could reuse the built-in abbreviations code?

Yeah, I was actually browsing the abbreviations code.

However I will implement the editing of the snippets first which probably requires writing the configuration dialog so it might take a while.

You might implement that properties box I sent you, but make the textCtrl a wxTE_MULTILINE editor. That'd take the pressure off implementing an editor for awhile.

Code
	m_SnippetTextCtrl = new wxTextCtrl( this, ID_DEFAULT, wxT(""), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
bSizer1->Add( m_SnippetTextCtrl, 1, wxALL|wxEXPAND, 5 );

(http://img471.imageshack.us/img471/7443/graphic922200612555pmkg8.png)
Title: Re: Code snippet plugin
Post by: artoj on September 22, 2006, 09:00:24 pm
You might implement that properties box I sent you, but make the textCtrl a wxTE_MULTILINE editor. That'd take the pressure off implementing an editor for awhile.

I've started implementing it a bit other way, through Code::Blocks' internal editor. It works similar to your implementation of the external editor:

- Hook to EVT_EDITOR_SAVE and EVT_EDITOR_CLOSE events
- When user clicks Edit, create a temporary file and put the snippet to it, record the file name
- Use C::B API to open the file
- On EVT_EDITOR_SAVE check if the file name is recorded, if it is, transfer the text from the file to the snippet
- On EVT_EDITOR_CLOSE check if the file name is recorded, if it is, remove it

This is how it works in general, although I need EVT_EDITOR_OPEN to check if the current tree item id has already a file open etc.
Title: Re: Code snippet plugin
Post by: Pecan on September 22, 2006, 10:16:23 pm
I've started implementing it a bit other way, through Code::Blocks' internal editor. It works similar to your implementation of the external editor:

Wonderful !!

Speaking of implementations...

Please find attached the Catagory/snippet dragging code. It allows the user to drag snippets into and out of another Catagory or drag Catagories into and out of other Catagories.

I implemented it as an xml document that simply extracts and inserts the tree items using your Load/Save snippet xml routines.

I believe that finishes my promised code.



[attachment deleted by admin]
Title: Re: Code snippet plugin
Post by: artoj on September 22, 2006, 11:23:56 pm
Wonderful !!

Speaking of implementations...

Please find attached the Catagory/snippet dragging code. It allows the user to drag snippets into and out of another Catagory or drag Catagories into and out of other Catagories.

I implemented it as an xml document that simply extracts and inserts the tree items using your Load/Save snippet xml routines.

I believe that finishes my promised code.

Thanks! :)
Title: Re: Code snippet plugin
Post by: Pecan on September 28, 2006, 03:29:32 pm
Arto,

I've just discovered something great about CodeSnippets.

I can drag a forum url out of Firefox to a snippets category and it will create a snippet containing that url.

With the dragndrop additions I sent you, I can then drag the snippet back to Firefox, returning to that forum thread.

I was shocked!

I always wanted something like this. It's better than a bookmark because I can put the url along with/under the associated working code snippet category. Later, when I look back at the code snippet/file, the url discussion is right there.

Not only that, I can drag a bugReport/patch url to the relavent snippet category.
It's great!

I've made come changes to the dragndrop, specifically, 1) ability to automatically create an enclosing category when dragging a snippet to a snippet, 2) use of ctrl key to "copy" a snippet when dragging.

Have a look at the bottom of app.h to see the change log.
Maybe there's something there that you will find useful.
http://savefile.com/files/114566 (http://savefile.com/files/114566)
Thanks
pecan

ps, Your code taught me to correctly spell category.

Edit: 2006/09/28 9:35
I've just discovered that a snippet catagory will *always* be created when dragging a snippet out of the tree. I'll fix this today. Just a heads up in case you find this problem in my code.
Title: Re: Code snippet plugin
Post by: Pecan on September 28, 2006, 07:32:31 pm
I've just discovered that a snippet catagory will *always* be created when dragging a snippet out of the tree. I'll fix this today. Just a heads up in case you find this problem in my code.

Arto,

The problem was in CodeSnippetsWindow::OnEndDrag(). The very code I've hoped you'd check out. I'm embarrased.
 
Below is a corrected version.

http://savefile.com/files/115267 (http://savefile.com/files/115267)
Direct link:
http://dl1u.savefile.com/59d423f987ffe01b56b777f3145577f5/cbSnipList3.zip
 (http://dl1u.savefile.com/59d423f987ffe01b56b777f3145577f5/cbSnipList3.zip)
FileFactory:http://www.filefactory.com/file/957265/ (http://www.filefactory.com/file/957265/)

Thanks
pecan
Title: Re: Code snippet plugin
Post by: artoj on November 02, 2006, 04:37:25 pm
I've commited some small changes to SVN. The editing of the snippets is written, but I'm very unhappy how it turned out; it's very complex and hacky (over 300 lines of new code). I have an alternative solution in mind and I'm going to investigate it further.

    Arto
Title: Re: Code snippet plugin
Post by: Pecan on April 03, 2007, 11:17:35 pm
Title: Re: Code snippet plugin
Post by: mike__t on April 10, 2007, 02:46:30 am
It didn't break my build on Linux, but the debugger hangs on startup when this plug-in is enabled.  Disabling it allows me to debug again.

-Mike
Title: Re: Code snippet plugin
Post by: Wahooney on April 10, 2007, 03:50:01 pm
There are three features that will make Code Snippets (which are damn handy already) even better, namely:


The first two features are the same as those found in the abbreviation tool. It will make writing things like class definitions that much more practical in code snippets.

Thanks :)
Title: Re: Code snippet plugin
Post by: Pecan on April 10, 2007, 07:47:18 pm
It didn't break my build on Linux, but the debugger hangs on startup when this plug-in is enabled.  Disabling it allows me to debug again.

-Mike


Fixed: SVN 3823

Thanks for the report
Title: Re: Code snippet plugin
Post by: Wahooney on May 04, 2007, 01:59:26 am
I don't know if the pipe and macro functionality were there before or if you added it after, either way, thanks!!! It's such a kick ass tool now!
Title: Re: Code snippet plugin
Post by: yop on July 17, 2007, 11:14:04 pm
Can the positioning of the tool be saved in a layout? I have a "Debug view" and a "Code view" and I save the "Code view" with the Snippets window docked where I want it to be. When I start a debugging session the "Debug view" is automatically started and when the debug session ends and the "Code view" is up again the Code Snippets window disappears. Such a beautiful little tool shouldn't be that shy ;-)
Title: Re: Code snippet plugin
Post by: Pecan on July 17, 2007, 11:37:42 pm
Can the positioning of the tool be saved in a layout? I have a "Debug view" and a "Code view" and I save the "Code view" with the Snippets window docked where I want it to be. When I start a debugging session the "Debug view" is automatically started and when the debug session ends and the "Code view" is up again the Code Snippets window disappears. Such a beautiful little tool shouldn't be that shy ;-)

I'm have trouble picturing what you're describing.
Could you give me a "step-by-step" to recreate the problem so I can  test it myself?
Title: Re: Code snippet plugin
Post by: yop on July 17, 2007, 11:44:40 pm
Gladly:

1. Make sure that Code Snippets dialog is visible
2. View->Layouts->Save Current->test (or whatever)
3. View->Layouts->Code::Blocks default
4. View->Layouts->test

In step 4. I would expect that the Code Snippets dialog would come up again but it doesn't. My main problem is what I described that I have registered a different layout for my debugging sessions that falls back to another one when the debugger finishes and I would like to have the Code Snippets dialog in my "default" layout.
Title: Re: Code snippet plugin
Post by: dmoore on July 20, 2007, 03:48:50 pm
PS: All you need to do to implement yop's request is to create the dockable in the plugin's OnAttach and remove it in OnRelease. Layout manager will automatically record its state. Don't add/remove the dockable outside of these places or you will just confuse the layout manager. To control display of Codesnippets, just use show/hide events in CodeBlocksDockEvents.
Title: Re: Code snippet plugin
Post by: Pecan on July 20, 2007, 09:08:24 pm
PS: All you need to do to implement yop's request is to create the dockable in the plugin's OnAttach and remove it in OnRelease. Layout manager will automatically record its state. Don't add/remove the dockable outside of these places or you will just confuse the layout manager. To control display of Codesnippets, just use show/hide events in CodeBlocksDockEvents.

Unfortunately, that's what it looks like I have to do.

It also means that all that data (the whole xml file) will be kept in memory when the window is hidden, even tho it isn't being referenced or used.

I'm getting more and more disappointed in wxAUI. It provides very little info (events) for the window owner, and forces awful inefficient use of resources by the programmer.


Title: Re: Code snippet plugin
Post by: dmoore on July 20, 2007, 09:35:02 pm
i think the version of AUI in wx2.8 offers more events. (I was under the impression you could at least receive close button notification for the dockables even under wx2.6)
Title: Re: Code snippet plugin
Post by: Pecan on July 22, 2007, 06:22:43 am
Can the positioning of the tool be saved in a layout? I have a "Debug view" and a "Code view" and I save the "Code view" with the Snippets window docked where I want it to be. When I start a debugging session the "Debug view" is automatically started and when the debug session ends and the "Code view" is up again the Code Snippets window disappears. Such a beautiful little tool shouldn't be that shy ;-)

fixed SVN 4288

Thanks for the report.
Title: Re: Code snippet plugin
Post by: yop on July 22, 2007, 10:22:18 am
Just updated, it's perfect.
Title: Re:
Post by: Deschamps on June 06, 2010, 12:39:06 pm
Sorry for bumping a really old thread, but I suppose that this is the correct place to post it.

I'm not sure if this issue is related to installing Code::Blocks in my box after building it, or (I bet for this last) launching C::B as a privileged user (yes, I started X as root, I know it's stupid), but the fact is that after that I've noted the existence of a /codeblocks folder in my root directory, only containing the standard codesnippets.ini. I suppose that this behavior is related to this plugin, and should be corrected.

My environment: Archlinux i686, gcc 4.5.0, wxGTK 2.8.11, C::B from svn repository (currently rev.6332).

Thanks.