Page 1 of 1
Run Tool on Selection Only
Posted: Thu Dec 03, 2009 2:14 pm
by ds0934
I'm sure this might not fit with all languages, but it would be nice to be able to highlight a section of code (maybe one routine or block) and run it with a selected Tool to view the results. Rather than running the tool against the entire file, just run it against what is selected.
Posted: Fri Dec 04, 2009 6:57 am
by Mr. Code Monkey
Agreed; that would be handy.
Posted: Mon Dec 07, 2009 9:41 pm
by H. Camphausen
Hmm, not too far ago I wrote a little script to achive just this. The script is written in Perl (and aimed to run "Perl snippets"), but adopting the script to run arbitrary programs shoud not be too hard.
I invoke the script as a TextPad custom tool.
Prerequisites:
- a working installation of Perl (available at
www.activestate.com)
- the Perl module Win32::Clipboard (part of ActiveState's Perl package)
If you are interested, just leave a note.
Posted: Mon Dec 07, 2009 10:08 pm
by Mr. Code Monkey
H. Camphausen wrote:Hmm, not too far ago I wrote a little script to achive just this. The script is written in Perl...
Sounds useful. Can you not paste the script here using
Posted: Mon Dec 07, 2009 10:47 pm
by ben_josephs
Have a look at my Perl script at the end of
http://forums.textpad.com/viewtopic.php?t=4890&start=15 (2006-04-19).
This method of implementing a script to manipulate a document in TextPad is a far from satisfactory. Such a script is tricky to write, it runs too slowly, and because of it works by sending keystrokes to TextPad, it requires you not to type anything while it's running.
TextPad's usefulness would be much increased if it provided a programming interface and supported scripts that use it.
Posted: Tue Dec 15, 2009 8:13 pm
by H. Camphausen
@Mr. Code Monkey:
It's been a while now, but here you go ... well, no code box (looked ugly), just a link (two, actually):
http://www.textix.de/perlix/index.htm
http://www.textix.de/perlix/perl.runsnippet.zip
No doc available, sorry. (Except for a few hints within the script.)
Cheerio, H.
Posted: Tue Dec 15, 2009 10:35 pm
by Mr. Code Monkey
Thank you.
I'll see if I can't gin up a python version one of these days.
Posted: Fri Jul 15, 2011 9:02 am
by trids
I have created a tool to do precisely this .. and it's available as a TextPad Add-on
Although this add-on (mysl3.zip) runs your text selection as a SQLite3 script/query, it can easily be modfied to execute your selection as any other language that has a commandline interface. Eg: AutoIt3, Python, etc
In fact, i do have another one which uses the same approach that runs python selections, but have not as yet sent it in for inclusion with the add-ons. I will repost here once I have -- it might make it easier to see how to clone and modify it for whatever language you want to support, when you have two examples to compare.
Meantime, you can take a look at the fully documented SQLite3 one (msyl3.zip, above), and see if you can modify it yourself for your preferred language.
edit: typos