Run Tool on Selection Only
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
Run Tool on Selection Only
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.
-
- Posts: 2
- Joined: Mon Dec 07, 2009 5:38 pm
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.
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.
- Mr. Code Monkey
- Posts: 24
- Joined: Thu Jul 30, 2009 4:59 am
Sounds useful. Can you not paste the script here usingH. Camphausen wrote:Hmm, not too far ago I wrote a little script to achive just this. The script is written in Perl...
Code: Select all
a code box?
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
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.
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.
-
- Posts: 2
- Joined: Mon Dec 07, 2009 5:38 pm
@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.
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.
- Mr. Code Monkey
- Posts: 24
- Joined: Thu Jul 30, 2009 4:59 am
Thank you.H. Camphausen wrote:@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.
I'll see if I can't gin up a python version one of these days.
I have created a tool to do precisely this .. and it's available as a TextPad Add-on
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
- Direct download
- Official Textpad "Add-ons" page ... Search the page for "SQLite3"
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