[SVN] RFC: async window support for tm_dialog

Chris Thomas chris at cjack.com
Wed Nov 29 01:24:39 UTC 2006


>> nt to retrieve parameter values on a user action, and there isn't a  
>> way to perform a callback yet. Perhaps export a new IBAction from  
>> the File Owner that dumps the parameters to stdout?
>
> Exporting a new action sounds like the way to go. Though using a  
> scheme similar to the returnArguments:«with variable arguments» --  
> this turned out to be far more useful than the performButtonClick: I  
> first did.
>
> But when we open an async. window, where exactly is stdout?
>
> I think for this to work, tm_dialog still needs to stall, but first  
> write out the window token (on stdout), and then optionally the  
> arguments to the exported method.
>
> So we end up (in the using script) launching tm_dialog in a  
> subprocess and do select() on its output pipe, to see if there is  
> data -- but since “packets” are sent, we also have the job of  
> determining boundaries (i.e. when have we read enough to parse it as  
> a plist and pass that on).

I think what's needed is a separate invocation of tm_dialog, so you'd  
have something like a standard event loop (psuedocode):

$tm_dialog -a --parameters '{wrapAround = 1; regExp = 1;}' $TM_NIBS/ 
SearchDialog.nib
[...get window token in $token...]

# event loop
while( 1 )
{
	# wait for user to press something
	$tm_dialog --wait-for-input $token
	... check plist to determine control clicked, etc ...
}


>> • There's a possibility that windows not attached to a process  
>> could be orphaned, which would require users to kill the window on  
>> the command line (if the window doesn't have a close box). If a  
>> script is handling errors properly, this shouldn't be a problem.  
>> You can already get into this situation now with CocoaDialog and  
>> suchlike, but the remedy is slightly different in that you will  
>> need to use tm_dialog to kill the window rather than killing an  
>> external process.
>
> We could maybe add a --list which lists ‘active’ tokens. I am sure  
> the need to kill a window while debugging will come up ;)

This occurred to me today, yup.

> As for the code: You would make me really happy if the style (i.e.  
> wrt spacing and indent) would follow the rest of the source :) I try  
> to do the same for you when I patch CommitWindow etc. ;)

I was trying to match the style, believe it or not. :) I'll do a pass  
to clean this up before checking anything in.

Chris




More information about the textmate-dev mailing list