On Sep 6, 2012, at 7:35 PM, Allan Odgaard wrote:

> On Sep 5, 2012, at 10:37 AM, Hans-Jörg Bibiko <[email protected]> wrote:
> 
>> […] How about to enhance this url scheme to support other "hosts" like 
>> "open"?
> 
> Well, I think the URL scheme should be for more “global” actions. Not 
> per-document actions, since there is no good way to specify what document we 
> wish to work on, and also, this seems a bit like just hacking in some poor 
> man’s scripting system using something which is not meant for it, e.g. the 
> security issue you mention (which just tax general use and make it useless 
> outside a TM context despite being a global URL scheme).

I agree.


> 
>> […] using an internal TM session ID which is accessible via a TM_ shell 
>> variable.
>> This session ID will be generated if TM2 starts, any command invoked from 
>> TM2 knows that ID and passes it through the txmt:/ url back to TM2; and the 
>> method "handleTxMtURL" simply checks the internal against the passed one.
> 
> If this is for commands with HTML output we already have a TextMate 
> JavaScript object. This seems better to use for communication than a global 
> URL scheme: 
> https://github.com/textmate/textmate/blob/master/Frameworks/HTMLOutput/src/helpers/HOJSBridge.mm#L42
> 
> I haven’t given scripting API that much thought, but if we add it, let’s try 
> to do it right :)

Yes :)

> There’s a major challenge though in figuring out what exactly should be used, 
> AppleScript is just so God damn awful, but sort of the only system for 
> “scripted” application IPC. Though it might be bearable if used with 
> AppScript.

An other 'quite easy', modular, and clean way would be to use $DIALOG plugin 
for that task. Since the current version did implement some commands as 
'x-insert' (which has a bug - see below), 'menu', etc. we can make usage of 
this mechanism to add some more commands like selecting stuff, getting run-time 
vars, etc. As far as I see it the only missing thing is a kind of AppleScript 
to $DIALOG bridge as for HTML-JavaScript but this couldn't be so difficult.

##########

x-insert bug:

HTML-JavaScript tmcommand which makes usage of e.g. this:

function insertChar(c) {
        cmd = "\"$DIALOG\" x-insert --text '"+ c +"'";
        TextMate.system(cmd, null);
}

This won't work because of PlugIns > dialog > Commands > Utilities > 
TextMate.mm:

void insert_text (NSString* someText)
{
        if(id textView = [NSApp targetForAction:@selector(insertText:)])
                [textView insertText:someText];
}

[NSApp targetForAction:@selector(insertText:)] returned in my example a 
NSButton. That's why it should look for the current OakTextView first, I think.

Kind regards,
--Hans

_______________________________________________
textmate-dev mailing list
[email protected]
http://lists.macromates.com/listinfo/textmate-dev

Reply via email to