Last active
May 7, 2016 07:06
-
-
Save jlieske/4e23c0d5afe83798afad54529b2d399a to your computer and use it in GitHub Desktop.
BBEdit scripts to show issue opening result browser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/osascript -l AppleScript | |
-- This script will open the BBEdit result browser. | |
tell application "BBEdit" | |
set e to {¬ | |
result_kind:note_kind,¬ | |
result_file:"/System/Library/ScriptingDefinitions/CocoaStandard.sdef",¬ | |
result_line:1,¬ | |
message:"This browser will open"¬ | |
} | |
make new results browser¬ | |
with properties {name:"AppleScript Check"}¬ | |
with data {e} | |
end tell | |
-- The raw AppleEvent is | |
-- aevt('core'\'crel' transactionID=0 sourcePSN=[pid=16452] timeout=7200 eventSource=3 sourceUID=1965 sourceGID=1990 sourceEUID=1965 sourceEGID=1990 sourcePID=16452 auditToken=[1965,1965,1990,1965,1990,16452,100008,514759]{ 'kocl':type('RslW'), 'prdt':reco({ 'pnam':utxt('utxt'(TEXT("AppleScript Check"))) }), 'data':list([ reco({ 'Ersl':enum('Note'), 'Efil':utxt('utxt'(TEXT("/System/Library/ScriptingDefinitions/CocoaStandard.sdef"))), 'Elin':long(1), 'Etxt':utxt('utxt'(TEXT("This browser will open"))) }) ]), &'subj':null(), &'csig':magn(65536) }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/osascript -l JavaScript | |
// This script should open the BBEdit result browser, but it fails with the | |
// message "Error -1701: Parameter is missing." | |
var bbedit = Application("BBEdit"); | |
var e = { | |
result_kind: "note_kind", | |
result_file: "/System/Library/ScriptingDefinitions/CocoaStandard.sdef", | |
result_line: 1, | |
message: "This browser won't open" | |
}; | |
//e = bbedit.ResultEntry(e).make(); // This generates error "Message not understood. (-1708)". | |
var rb = bbedit.ResultsBrowser({name: "JavaScript Check"}, [e]); | |
rb.make() | |
// The problem is that the result_kind property should be passed as an | |
// enumerated value (raw event 'Ersl'), but it is passed as a string. | |
// The raw AppleEvent is | |
// aevt('core'\'crel' transactionID=0 sourcePSN=[pid=16488] timeout=7200 eventSource=3 sourceUID=1965 sourceGID=1990 sourceEUID=1965 sourceEGID=1990 sourcePID=16488 auditToken=[1965,1965,1990,1965,1990,16488,100008,514795]{ 'kocl':type('RslW'), 'prdt':reco({ 'pnam':utxt('utxt'(TEXT("JavaScript Check"))) }), 'data':list([ reco({ 'usrf':list([ utxt('utxt'(TEXT("result_kind"))), utxt('utxt'(TEXT("note_kind"))), utxt('utxt'(TEXT("result_file"))), utxt('utxt'(TEXT("/System/Library/ScriptingDefinitions/CocoaStandard.sdef"))), utxt('utxt'(TEXT("result_line"))), long(1), utxt('utxt'(TEXT("message"))), utxt('utxt'(TEXT("This browser won't open"))) ]) }) ]), &'subj':null(), &'csig':long(65536) }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# This script will open the BBEdit result browser. | |
import ScriptingBridge as sb | |
import struct | |
def fourCharCode(string): | |
"Convert a four-char code string into a 32-bit int." | |
return struct.unpack('>I', string)[0] | |
BBEdit = sb.SBApplication.applicationWithBundleIdentifier_("com.barebones.BBEdit") | |
ResultsBrowser = BBEdit.classForScriptingClass_("results browser") | |
data = [{ | |
'result_kind': "note_kind", | |
'result_file': "/System/Library/ScriptingDefinitions/CocoaStandard.sdef", | |
'result_line': 1, | |
'message': "This browser will open!" | |
}] | |
properties = {'name': "JavaScript Check"} | |
browserSpecifier = ResultsBrowser.alloc().initWithElementCode_properties_data_( | |
fourCharCode("RslW"), properties, data) | |
BBEdit.windows().addObject_(browserSpecifier) | |
# The raw AppleEvent is | |
# aevt('core'\'crel' transactionID=0 returnID=22799 sourcePSN=[0x0,5ec5ec "Python"] eventSource=3 sourceUID=1965 sourceGID=1990 sourceEUID=1965 sourceEGID=1990 sourcePID=17769 auditToken=[1965,1965,1990,1965,1990,17769,100008,516076]{ 'kocl':type('RslW'), 'data':list([ reco({ 'Elin':long(1), 'Etxt':utxt('utxt'(TEXT("This browser will open!"))), 'Efil':utxt('utxt'(TEXT("/System/Library/ScriptingDefinitions/CocoaStandard.sdef"))), 'Ersl':utxt('utxt'(TEXT("note_kind"))) }) ]), 'prdt':reco({ 'pnam':utxt('utxt'(TEXT("JavaScript Check"))) }), &'subj':null() }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment