Hi all. Can someone point me to a basic example of a dialog from inside a ruby code? My needs are basic: at some point my code computes a certain string; I want to check the string, edit it by hand if necessary, and then continue. So I just need something like the example in Allan's screencast about tmDialog, only from inside some ruby code in a TextMate command.
Thanks, Piero
#!/usr/bin/env ruby require ENV["TM_SUPPORT_PATH"] + "/lib/dialog.rb" str = "hi there" newstr = Dialog.request_string(:title => "Change me!", :prompt => "Please change me:", :default => str) if newstr.nil? print "You pressed Cancel!" else print "Here's the new string: #{newstr}" end
On Mar 2, 2007, at 12:04 PM, Piero D'Ancona wrote:
Hi all. Can someone point me to a basic example of a dialog from inside a ruby code? My needs are basic: at some point my code computes a certain string; I want to check the string, edit it by hand if necessary, and then continue. So I just need something like the example in Allan's screencast about tmDialog, only from inside some ruby code in a TextMate command.
Thanks, Piero
Haris Skiadas Department of Mathematics and Computer Science Hanover College
Charilaos Skiadas <skiadas@...> writes:
#!/usr/bin/env ruby require ENV["TM_SUPPORT_PATH"] + "/lib/dialog.rb" str = "hi there" newstr = Dialog.request_string(:title => "Change me!", :prompt => "Please change me:", :default => str) if newstr.nil? print "You pressed Cancel!" else print "Here's the new string: #{newstr}" end
Amazing (and so simple). Thanks Haris!
Piero
On Mar 2, 2007, at 12:32 PM, Piero D'Ancona wrote:
Amazing (and so simple). Thanks Haris!
Thanks to all the people working on the dialog.rb library. If you look around in there you'll find all sorts of goodies.
Piero
Haris Skiadas Department of Mathematics and Computer Science Hanover College
On Mar 2, 2007, at 12:38 PM, Piero D'Ancona wrote:
I'll do some homework. Is there a way to adjust the size of the dialog window?
Not to my knowledge, but of course you can create your own custom tm_dialog nib with text areas and everything. This command actually still uses CocoaDialog (shouldn't we change that?).
Creating a custom nib is a tad more difficult, but you can have a look at the date command in the GTDAlt bundle. It uses a custom nib. Let me know if you have questions. (And of course the screencast is supposed to show you want to do). You'll need to familiarize yourself with Interface Builder a bit though.
Piero
Haris Skiadas Department of Mathematics and Computer Science Hanover College