[TxMt] Replacement for read() system function for scriptmates.
Luke Daley
ld at ldaley.com
Sun Mar 2 07:37:55 UTC 2008
Hi,
I have added an xcode project to the bundles repo (http://
macromates.com/svn/Bundles/trunk/Review/Tools/tmread/) called tmread
(it need's a better name). From the help file ...
"The goal of this is to facilitate scripts/commands running via
TextMate that require user input to use tm_dialog to get the input,
where typically the user would enter it on the command line."
In essence, you can use this to run scripts via textmate and have
textmate present a dialog to the user to allow them to enter input
into the process.
I need some help to test this. It passed under every circumstance I
can concoct, but of course there could be lurking bugs.
To fully make use of this though, you need to be a bit clever about
how you write the output of the running process to wherever your are
writing it to (typically the HTML output window). Consider thing's
like RubyMate. It executes a ruby script, writing the output of said
script to the html output window. It currently does this on a line by
line basis. This is problematic if you have the following script ...
#!/usr/bin/env ruby
$stdout.print("Please enter username: ")
username = STDIN.gets
The problem here is that RubyMate would not output "Please enter
username: " before the dialog is presented to the user asking for the
username. So the user won't really know what they are inputting.
I am not 100% sure how to solve this. Parsing the input line by line
is too convenient to through out the window. What we really need is a
way to identify when it is likely that the script we are running is
presenting a prompt and then pass that through as a line, considering
that most prompts end when a newline is entered. I am at a bit of a
loss on how to do this.
I would encourage anyone interested to grab tmread from the repo to
read the readme, build it and have a play so we can catch any issues.
LD.
More information about the textmate
mailing list