On 25. Jun 2007, at 10:50, Brett Terpstra wrote:
Is it possible to create a "palette" using tm_dialog? From a ruby shell I can create a dialog that reads in a list and then lets me load a nib asynchronously, clicking add multiple times. It then returns all of the added choices when I close the nib. There are two issues I'm working through:
- When I run the same code from within a command, the dialog
(nib) freezes and takes no input until I cancel the command. I'm using the wait_for_command loop from the dialog.rb code. I then manually close the nib from the terminal. Is there something I'm missing?
If you run tm_dialog from a command, and you plan on not opening the dialog as modal, you should ensure your command detaches properly.
If your command holds the ruby script itself then do something like:
#!/usr/bin/env ruby -wKU
# since TM won’t wait for us, send output to console STDOUT.reopen('/dev/console', 'w') STDERR.reopen('/dev/console', 'w')
pid = Process.fork do # actual code starts here sleep 2 %x{osascript -e 'tell app "TextMate" to insert "${0:Hello, world}" as snippet yes'} end
Process.detach(pid)
- I'd like to be able to keep the "palette" open and insert
snippets (or tags in this case) as I go, rather than upon window close. I'd like to use this for both the Autotag bundle and the Wordpress bundle, keeping a palette of Tags/Wordpress snippets open and insertable at any time. Any way to do this?
Yes, using -a and -w to wait for an action, then use osascript as in the above command to actually insert the stuff and go back to -w.
You can bind the doubleClickTarget/Argument of the table view as shown in the latest dialog to make tm_dialog “return” when an item in your table view is double clicked (remember to disable editable for the table column, so that double click does not start editing), then just go back to -w(ait) again (instead of closing the palette with -x).
I believe you can set the attributes of the window to be utility / always on top / non-activating or something like that to make it act like a palette.