Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » PHP Development Tools (PDT) » External Tools - selected text to tool's stdin
External Tools - selected text to tool's stdin [message #529633] Mon, 26 April 2010 15:19 Go to next message
hemil is currently offline hemilFriend
Messages: 4
Registered: April 2010
Junior Member
Hello,

When I define an External Tool, is there a way to pass currently selected text to the tool's standard input?

I've been using this feature a lot in EditPadPro. I mark a piece of text, click a tool and the text is replaced by whatever output from the tool.

Thanks in advance...





Re: External Tools - selected text to tool's stdin [message #529796 is a reply to message #529633] Tue, 27 April 2010 09:10 Go to previous messageGo to next message
dominik is currently offline dominikFriend
Messages: 122
Registered: July 2009
Senior Member
On 2010-04-26 17:19, hemil wrote:
> Hello,
>
> When I define an External Tool, is there a way to pass currently
> selected text to the tool's standard input?

Sounds like you are looking for this:
${selected_text}

For input use standard pipes or just write that to temp file and then pass this
file to Your program.


> I've been using this feature a lot in EditPadPro. I mark a piece of
> text, click a tool and the text is replaced by whatever output from the
> tool.

Should be easy, I hope You will succeed :)
Please then share final script :)

dominik
Re: External Tools - selected text to tool's stdin [message #529878 is a reply to message #529633] Tue, 27 April 2010 14:35 Go to previous messageGo to next message
hemil is currently offline hemilFriend
Messages: 4
Registered: April 2010
Junior Member
Thanks for the suggestion.
I didn't mention I am on windows xp.

I am unable to send the ${selected_text} data to the command line tool's standard input. Is this possible with Eclipse's External Tools settings?

A compromise I arrived at works like in the following example, which runs the marked text as PHP code and displays the result in the console panel.

In External Tools Configuration:
Location: C:\php\php-win.exe
Arguments: -r "${selected_text}"

The selected text variable in Arguments must be enclosed in double quotes.
The selected text in the editor cannot contain double quotes.
Re: External Tools - selected text to tool's stdin [message #530536 is a reply to message #529878] Fri, 30 April 2010 02:49 Go to previous messageGo to next message
Toshihiro Izumi is currently offline Toshihiro IzumiFriend
Messages: 360
Registered: July 2009
Location: Japan
Senior Member
>I am unable to send the ${selected_text} data to the command line tool's standard input. Is this possible with Eclipse's External Tools settings?
In this way.
Location: c:\windows\system32\cmd.exe
Arguments: /c echo ${selected_text}|php.exe

However,
>The selected text in the editor cannot contain double quotes.
Exactly...

Also,
>and the text is replaced by whatever output from the tool.
I believe it is impossible.
Unless there is a plugin which can
1. execute an external tool
2. send selected text in the editor to stdin
3. grab output from the tool
4. replace selected text with grabbed text
Any lacks?
Re: External Tools - selected text to tool's stdin [message #530621 is a reply to message #529633] Fri, 30 April 2010 10:59 Go to previous messageGo to next message
hemil is currently offline hemilFriend
Messages: 4
Registered: April 2010
Junior Member
Thanks a lot for the advice.
It works for me.

I came across another character which the selected text cannot contain - the ampersand &

A little observation - on the build tab in External Tools Configuration panel we can uncheck "Build before launch" to prevent the Save changes prompt when running the tool. We're only only using ${selected_text}, so the file will remain untouched.

Re: External Tools - selected text to tool's stdin [message #530865 is a reply to message #530536] Sun, 02 May 2010 02:51 Go to previous messageGo to next message
Toshihiro Izumi is currently offline Toshihiro IzumiFriend
Messages: 360
Registered: July 2009
Location: Japan
Senior Member
Quote:
Unless there is a plugin which can
1. execute an external tool
2. send selected text in the editor to stdin
3. grab output from the tool
4. replace selected text with grabbed text


http://sourceforge.jp/projects/pdt-tools/releases/?package_i d=9452
->Substituter
Re: External Tools - selected text to tool's stdin [message #531219 is a reply to message #529633] Tue, 04 May 2010 08:39 Go to previous messageGo to next message
hemil is currently offline hemilFriend
Messages: 4
Registered: April 2010
Junior Member
I didn't realize you were planning to create such a plugin.
Wonderful! Thank you.

I am testing it right now. Here are my notes:
- works well when the selection is fairly short
- when I marked a larger volume of text, eclipse (galileo) hangs,
90 chars OK, 100 chars - eclipse stops responding
- if I needed to set up several tools using this plugin, what would be the procedure?
- would it be possible to choose between replacing the selected text and outputting the result to the console individually for each tool?

Thanks for your time, don't work on this anymore unless it goes with the flow Smile



Re: External Tools - selected text to tool's stdin [message #532061 is a reply to message #529633] Fri, 07 May 2010 00:27 Go to previous messageGo to next message
Toshihiro Izumi is currently offline Toshihiro IzumiFriend
Messages: 360
Registered: July 2009
Location: Japan
Senior Member
> - when I marked a larger volume of text, eclipse (galileo) hangs,
> 90 chars OK, 100 chars - eclipse stops responding
Sorry! The plugin had too cheap implementation.

> - if I needed to set up several tools using this plugin, what would be the procedure?
It is impossible for now.

> - would it be possible to choose between replacing the selected text and outputting the result to the console individually for each tool?
It is impossible for now too.

I will update the plugin in a few days. Smile
Re: External Tools - selected text to tool's stdin [message #551539 is a reply to message #529878] Fri, 06 August 2010 21:45 Go to previous messageGo to next message
Kristian Wiborg is currently offline Kristian WiborgFriend
Messages: 5
Registered: August 2010
Junior Member
hemil wrote on Tue, 27 April 2010 10:35
Thanks for the suggestion.
I didn't mention I am on windows xp.

I am unable to send the ${selected_text} data to the command line tool's standard input. Is this possible with Eclipse's External Tools settings?

A compromise I arrived at works like in the following example, which runs the marked text as PHP code and displays the result in the console panel.

In External Tools Configuration:
Location: C:\php\php-win.exe
Arguments: -r "${selected_text}"

The selected text variable in Arguments must be enclosed in double quotes.
The selected text in the editor cannot contain double quotes.



This is very cool! I I think will use this a lot... Also to execute PHP scripts that genereate/return slug-text, database queries (based on a table name) and maybe a few other things Smile
Re: External Tools - selected text to tool's stdin [message #1709974 is a reply to message #551539] Fri, 02 October 2015 10:37 Go to previous message
Darren Sharman is currently offline Darren SharmanFriend
Messages: 1
Registered: October 2015
Junior Member
Hi,

I am looking for a tool exactly like the Substituter tool mentioned above.

It appears the link to the tool is now dead. Does anyone know where I can get this plugin from, or know of anything with similar functionality?

Regards,

Darren
Previous Topic:Indicating syntax error when it's none
Next Topic:PDT 3.6 released with Mars.1 !
Goto Forum:
  


Current Time: Tue May 22 14:17:49 GMT 2018

Powered by FUDForum. Page generated in 0.02276 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top