Template Enhancements

From: Jeremy Cowgar <jeremy_at_cowgar.com>
Date: Mon, 21 Jul 2008 18:19:12 -0400

Hello,

I made some template enhancements today. Some I have already submitted
but I think Angel was going to think about it. The first is what I
already submitted:

.mp_templates becomes a directory and under the directory you have
template files. The file names are the same as a mode name. So, you
could have template files named:

euphoria
python
ruby

And then one special template name "global" which will appear for all.
The internal load template function then loads global, then looks for a
mode specific template file and loads it as well if found. This means
when you are programming in Euphoria you are not presented with Python
or Ruby templates, or whatever modes you may be using.

Now, the second (new as of today) addition I made was greatly enhanced
templates. Here is what they look like:

%%Iup Callback
function on__at_Event name@(@Parameters@)
    return IUP_DEFAULT
end function
constant f_on__at_Event name@ = call_back({'+', routine_id("on__at_Function
name@")})

So, what the new insert template function does is it scans for all @...@
keys and builds a dynamic dialog off of that. From the above you would
have a dialog presented:

Event name: ____________________
Paramters: ______________________
                        [OK] [Cancel]

Now, let's say you fill in the Event name as "key_down" and the
parameters as "atom h"... this would be inserted into your code:

function on_key_down(atom h)
    return IUP_DEFAULT
end function
constant f_on_key_down = call_back({'+', routine_id("on_key_down")})

If your template does not have any @...@ then the dialog is never
presented and it inserts your template as it always did w/no user
interaction.

You can have as many @...@ keys as you would like. It will only present
a field for the first of any usage, i.e. above I used @Function name@
three times in the template but it was only in the dialog once, yet it
was replaced all three times in the template.

Does this sound like something that may be of interest into the core
Minimum Profit?

Jeremy Cowgar

-- 
To unsubscribe, send mail to mp-unsubscribe_at_lists.triptico.com.
Received on Tue Jul 22 2008 - 00:19:12 CEST

This archive was generated by hypermail 2.2.0 : Tue Jul 22 2008 - 00:19:28 CEST