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.
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".
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.
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.
Things that I'm proud of:But does it do Tetris?
- 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
Very cool, does it have multiple language support?
btw, how are snippets stored?
But does it do Tetris?Actually, I'm thinking more about Quake III, it's GPL so why not 8)
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
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... ;-)
-------------- 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.
Execution of 'update.bat' in 'C:\Projects\CodeBlocks\src\plugins\contrib\codesnippets' failed.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):
Nothing to be done.
@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
Both Morton and I have put the plug-in in our source tree at the level on contributed plug-ins. Hint hint ;-)
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!
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.
* drag/drop text from/to external apps (scite and StEdit are very useful).
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.)
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.
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.
* 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
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)
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"
Does this plugin do variable substitutions?
Does this plugin do variable substitutions?
No, it's in the TODO list.
OK. Perhaps you could reuse the built-in abbreviations code?
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.
m_SnippetTextCtrl = new wxTextCtrl( this, ID_DEFAULT, wxT(""), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
bSizer1->Add( m_SnippetTextCtrl, 1, wxALL|wxEXPAND, 5 );
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:
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.
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.
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
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 ;-)
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.
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 ;-)