BBEdit和TextWrangler CSS语法检查器1.0.1

我已经发布了一个小的1.0.1更新到我的CSS Syntax Checker for BBEdit and TextWrangler; the biggest change is that it is now compatible with Mac OS X 10.3.x.

Perl组件只需要改变即可我在用HTML ::实体将实体值转换为纯文本,但是HTML ::实体module is not installed by default on Mac OS X 10.3. Asking people to learn to useCPANjust so they can syntax-check their CSS files is a bit much to askThe fix was easy: I switched to theunescapeHTML()常规来自CGI.pm

AppleScript位需要更多关注The way the script was originally written, you could store the AppleScript and Perl scripts wherever you wanted on disk, so long as they were together in the same folderAppleScript使用的是Perl脚本我的路command, which returns the path to the AppleScript script itself; once it gets this path, the script can then look next to itself for the Perl script.

但是,AppleScript的我的路command only works this way on 10.4; on 10.3 and prior, it returns the path to the应用that is executing the script, not the path to the script file itself.

The workaround is that the AppleScript now checks what version of the OS is present, and only uses the我的路technique if running on 10.4.0 or laterOtherwise, it only looks in one hard-coded location: BBEdit’s (or TextWrangler’s) Scripts folder.

Another Tiger-ism in the original script is that I made use of the new-in-Tiger显示警报command, which produces much nicer-looking dialog alerts than the old显示对话框command. (See我的Tiger详细信息报告中的此条目举些例子。)

The workaround, once again, is to check for the version of the OS, and to use the new显示警报command only when running on Mac OS X 10.4.0 or later.

To be pedantic, it’s not the version of the OS I check against; rather it’s the version of AppleScriptAppleScript 1.10 is the version that shipped with Mac OS X 10.4, so checking for AppleScript 1.10 or later is more or less the same as checking whether you’re running on Mac OS X 10.4.0 or later.

这是一段示例代码:

-- Binary-coded decimal of applescript version 1.10
property AS_VERSION_1_10 : 17826208

on show_alert(the_title, the_message)
    if ((system attribute "ascv") ≥ AS_VERSION_1_10) then
        -- AppleScript 1.10 or later (10.4)
        display alert the_title message the_message
    else
        display dialog the_title & return & return & the_message ¬
            buttons {"OK"} default button 1 with icon note
    end if
    return
end show_alert

系统属性“ascv”is how you ask for the version of AppleScript; the value returned is a binary-coded decimal integerAt the beginning of the script, I set the propertyAS_VERSION_1_10to 17826208, which is the binary-coded decimal value for AppleScript version 1.10It’s better practice to define a constant with a sensible name than to compare against a seemingly arbitrary value like “17826208” repeatedly.

show_alert()是一个简单的实用例程,我打了一个耳机If you call it like this:

我的show_alert(“这是标题”,“这是消息。”)

然后结果在10.4上看起来像这样:

Mac OS X 10.4上show_alert()输出的屏幕截图

但在10.3或更早的时候看起来有点像这样:

Mac OS X 10.3上show_alert()输出的屏幕截图

(我说“有点”,因为这实际上是一个截图display dialogcommand taken on 10.4, because I’m just too lazy to bother getting a screenshot from the old iMac I have that’s still running 10.3甚至是输出显示对话框looks better on 10.4 than it did before, so the dialog will look even crustier when actually running on 10.3再看看我的Tiger详细报道for actual screenshots of the differences.)

最后,请注意show_alert()routine above will only compile under 10.4 or later, because older versions of the Standard Additions OSAX don’t define the显示警报命令Once compiled, the script works just fine on 10.3, but to compile it under 10.3, you need to use the raw Apple event syntax for the显示警报命令:«event sysodisA»

以前: 2005年会员奖的奖品
下一个: 会员号码