[TxMt] open Safari Source in TM
Ryan Schmidt
textmate-2005 at ryandesign.com
Fri Mar 4 09:28:19 UTC 2005
> On Thu, 3 Mar 2005 20:25:46 +0100, Allan Odgaard
> <allan at macromates.com> wrote:
>> On Mar 3, 2005, at 20:19, Nednieuws wrote:
>>
>>>> TextMate already has such a command for Safari, although it just
>>>> reloads, it doesn't ask. I just extended the command to favor
>>>> OmniWeb, if that browser is already running.
>>> I envision a configuration option for browser preference (maybe
>>> primary and secondary) and Cmd-R/Cmd-Opt-R :).
>>
>> Well, having it check which of the browsers are running and just use
>> the one which is, is probably desired in 99% of the cases (I have an
>> aversion toward different hot keys and settings).
>>
>> I guess the script could be smarter and detect when multiple browsers
>> are running. present a dialog where the user could choose, and even
>> make that choice sticky (see the recent get_doc_path.sh script I added
>> to the repository for an example of how to have bundle items manage
>> settings).
On 04.03.2005, at 00:07, Tijs wrote:
> I'm a bit new to the OS X platform (already i can't do without
> textmate!) but shouldn't it be possible to detect the default browser
> and refresh that. After i picked a different default browser, Firefox
> in my case, some apps seem to notice and open firefox instead of
> safari when a browser is needed (netnewswire for instance).
It's not that easy.
From an AppleScript perspective, you can open a web page in the default
browser with this command:
open location "http://www.example.com/"
However, opening a web page is the only thing you can instruct the
default web browser to do with a simple generic command. Anything more
complicated than that and you have to specifically script a particular
browser, according to the interfaces made available in its AppleScript
dictionary.
Looking at the AppleScript dictionary for Safari, the only way there
appears to be to reload a window would be by sending it JavaScript
commands, and I can't get that to work right now. Firefox has
practically no AppleScript support whatsoever. OmniWeb does appear to
have a reload command in its AppleScript dictionary. I haven't checked
the other browsers.
Bypassing the AppleScript dictionary, one could instead script the
application by telling to directly choose menu commands from the
menubar. This requires some system-wide preference to be enabled, and I
forget what it's called or where to find it.
In any case, you would have to have code that determines what the
current browser is, and then have a special case for each browser you
want to support in which you send it the correct AppleScript or menu
commands to do a reload.
As you see it is a somewhat involved exercise.
More information about the textmate
mailing list