View unanswered posts | View active topics

Reply to topic  [ 3 posts ] 
Advanced snippets with parameters 
Author Message

Joined: Thu Apr 29, 2010 9:39 pm
Posts: 133
Reply with quote
I'm going to build a plugin for insertion of complex snippets with user-specified parameters, like so:
for ({1}:int = 0; {1}<{2}.length; {1}++){

....where {1} and {2} will be specified in another file, something like this:

....that will be displayed in a GUI at the time of insertion:
Please configure your snippet:
Iterator : _i____
Array : _array___
[OK], [Cancel]

Is that clear? So in order to build something like this I need an event just before a snippet is inserted. At that point I can display my GUI, modify the snippet, and ask FD to insert it into the code file. I don't want a separate button/menu to add these snippets, that would add unnecessary complexity to the user experience.

I am NOT a newbie to C# or to the FD codebase. I built a few features that got integrated into the FD4 & FD5 trunks.

My questions:
  1. Is there an event just BEFORE a snippet is inserted?
  2. If not, where do I go about adding this event in the FD codebase?
  3. And how do I subscribe for such an event in a plugin?

Phillipe/Mika, if you would like this added into the trunk then I'll skip the plugin stuff and simply build this functionality into the respective codefiles itself.

Wed Jan 06, 2016 1:58 pm

Joined: Thu Feb 09, 2006 10:58 am
Posts: 1099
Location: Israel
Reply with quote
I think this is the function you are looking for in the code. I can't see any event handlers there: ... per.cs#L84

from here: ... ger.cs#L88

Anyway, I've never touched this code, so maybe I'm completely wrong.


Wed Jan 06, 2016 3:14 pm

Joined: Wed Aug 31, 2005 7:27 am
Posts: 12172
Location: London
Reply with quote
Try creating a snippet with that:
for ($$(Iterator=i,j,k):int = 0; $$(Iterator)<$$(Array=array,items).length; $$(Iterator)++){

It's described very briefly near the end of the Arguments documentation page: ... =Arguments

Fri Jan 08, 2016 11:56 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.