NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Code Snippets input


Joined: 05 Oct 2012
Posts: 3
Reply with quote
I use the code snippets all the time (through ctrl+j), but there is something I miss, namely an option to input something into the snippet itself when it is added to the code editor.
The cursor "|" sign is all good for placing the cursor at the "right" position once the code has been injected, but take the get/set functionality for example:
Code:

private $SomeVariable;
public getSomeVariable() { return $this->SomeVariable; }
public setSomeVariable($value) { $this->SomeVariable = $value; }

You can only replace "SomeVariable" with a "|" at one place, and you will have to find the places in the snippet to place your cursor and type "SomeVariable".
I know this is lazy, I am lazy at times Wink

My suggestion is to add a checkbox to the snippet editor which allows PhpED to prompt for some input and when the snippet is injected, @INPUT@ would be replaced with whatever the user entered into the prompt.
Code:

private $@INPUT@;
public get@INPUT@() { return $this->@INPUT@; }
public set@INPUT@($value) { $this->@INPUT@ = $value; }


This would be awesome, and would save me at least 5 seconds every day Wink
View user's profileFind all posts by JaniPellikkaSend private message


Joined: 05 Oct 2012
Posts: 3
Reply with quote
45 views and not a single person thinks this is a good idea?
View user's profileFind all posts by JaniPellikkaSend private message


Joined: 05 Sep 2013
Posts: 4
Reply with quote
IT would be cool if multiple | characters can be used in a snippet, and each time i press CTRL+| it would advance to the next input location. This way if i create a snippet that contains 5 | characters in different locations i can rip through each of them and type in the required text to complete the snippet.

Just me 2 cents though.
View user's profileFind all posts by probc1Send private message


Joined: 03 Nov 2012
Posts: 8
Location: United States
Reply with quote
agreed.. some more power in the code snippets could be useful.
View user's profileFind all posts by detainSend private message
Veteran

Joined: 15 Nov 2003
Posts: 118
Reply with quote
How about %1 %2 etc, thats quite a common identifier for replacements, windows uses %something% etc.. Using | seems a bit weird!

Ofcourse if you wanted to use %1 in your code, you'd need to escape it like this %%1

so...
(not real code, just an example)

Code:

%1 = ((%99%%4) == 0); // get modulo of 4 into %99
%2 = DoSomeWork();
%3 = TRUE;
%4 = TRUE;
if( %1 == %2 )
{   
    %3 = FALSE;
}
else
if( %1 > %2 )
{
    %4 = FALSE;
}
else
{
    %3 = %1;
}
View user's profileFind all posts by joebSend private message


Joined: 05 Oct 2012
Posts: 3
Reply with quote
I agree to the %1 %2 approach. This does make the snippet editor more powerful, and more complex.
The "popup" needs to be configurable so the author of the snippet can define how many input fields are required and labels for them.
I'm sure this is a no-brainer to the developers of PhpED though. Question is, will they even consider it?

Meanwhile, I have started a C# project that utilizes the script functionality to popup a customizable window with inputs (textbox,radio,combobox,checkbox), labels and of course OK and Cancel buttons.
Features it has now:

* GUI editor (Very quirky and buggy at the moment)
* Snippet template editor (very simple, no syntax highlight or such)

Basically, I assign ctrl+alt+J (or anything else) to trigger my script. Lets say I type "newprop" in the editor and press my shortcut combination, it will then trigger the script, passing "newprop" as an argument.
The program looks for a snippet named "newprop" and executes it, with it's associated GUI, then returns the processed template.

The template looks pretty much the same I had in my first post, but rather than having just @INPUT@ I can name them like @NAMEOFPROPERTY@ and @PROPERTYTYPE@ etc...
So, by naming my input field in the GUI editor "NameOfProperty" I know exactly where it is injected in the template (@NAMEOFPROPERTY@).

Any thoughts? Ideas?
I will make it available for download (both binary and source) if people are interested and I feel somewhat satisfied with it Wink
View user's profileFind all posts by JaniPellikkaSend private message


Joined: 03 Nov 2012
Posts: 8
Location: United States
Reply with quote
I'm very interested =)
View user's profileFind all posts by detainSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8340
Reply with quote
we have this feature request in our dev plans, but its priority is not too high, so it is still waiting for its time

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 26 Nov 2018
Posts: 36
Reply with quote
dmitri wrote:
we have this feature request in our dev plans, but its priority is not too high, so it is still waiting for its time

It's been 8 years, I don't know, has anything been solved?
View user's profileFind all posts by piotrSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8340
Reply with quote
Piotr, if it was the only feature on our plate, we'd have it done long ago. Obviously, our highest priority is php.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website
Code Snippets input
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
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic