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:
1. 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?
2. 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?
Thanks, Brett
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.
I think I've got the gist of this, but the osascript part errors out because the dialog is the frontmost window when clicked and it can't insert text there. Any workaround for that?
Brett
On Jun 25, 2007, at 6:55 AM, Allan Odgaard wrote:
[snip]
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.
On 27. Jun 2007, at 23:31, Brett Terpstra wrote:
I think I've got the gist of this, but the osascript part errors out because the dialog is the frontmost window when clicked and it can't insert text there. Any workaround for that?
Let me test that and if it is the case (likely) I can fix it for next build.
On 27. Jun 2007, at 23:31, Brett Terpstra wrote:
I think I've got the gist of this, but the osascript part errors out because the dialog is the frontmost window when clicked and it can't insert text there. Any workaround for that?
I looked at the code involved, and I can’t see a problem with it.
Can you quote the error reported and/or send a reproducible example?
Thanks for checking.
From Console:
2007-07-06 15:18:56.128 TextMate[12076] Command: TextMate.InsertString Direct Parameter: apple, applescript, applications Receivers: (null) Arguments: {"" = "apple, applescript, applications"; asSnippet = 0; } 2007-07-06 15:18:56.128 TextMate[12076] [<TMDNibWindowController 0x168e5bd0> valueForUndefinedKey:]: this class is not key value coding-compliant for the key textView. 2007-07-06 15:18:56.128 TextMate[12076] Result: (null) 2007-07-06 15:18:56.128 TextMate[12076] Error: 8 "NSInternalScriptError" 23:78: execution error: TextMate got an error: NSInternalScriptError (8)
So the key is blank. The command I sent was:
returnedtags.map {|tag| tagslist += ", " unless tagslist == '' tagslist += tag } STDOUT.print tagslist.chomp %x{osascript -e 'tell app "TextMate" to insert "#{tagslist.chomp}" as snippet no'}
Thanks, Brett
On Jul 6, 2007, at 7:26 AM, Allan Odgaard wrote:
On 27. Jun 2007, at 23:31, Brett Terpstra wrote:
I think I've got the gist of this, but the osascript part errors out because the dialog is the frontmost window when clicked and it can't insert text there. Any workaround for that?
I looked at the code involved, and I can’t see a problem with it.
Can you quote the error reported and/or send a reproducible example?
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate