text
stringlengths
0
15.7k
source
stringlengths
6
112
set _result to set_persistent_number_variable var to _val
BetterTouchTool-Library.applescript
set _result to set_number_variable var to _val
BetterTouchTool-Library.applescript
if _result ≠ "success" then error "error: variable " & var & " was not set"
BetterTouchTool-Library.applescript
end setVar:toVal:persist:
BetterTouchTool-Library.applescript
on executeTrigger(uid)
BetterTouchTool-Library.applescript
set uid to checkUUID(uid)
BetterTouchTool-Library.applescript
tell application "BetterTouchTool" to execute_assigned_actions_for_trigger uid
BetterTouchTool-Library.applescript
end executeTrigger
BetterTouchTool-Library.applescript
on toggleVar(var)
BetterTouchTool-Library.applescript
set v to getVar(var, text)
BetterTouchTool-Library.applescript
if v = "true" then
BetterTouchTool-Library.applescript
my setVar:var toVal:false persist:true
BetterTouchTool-Library.applescript
my setVar:var toVal:true persist:true
BetterTouchTool-Library.applescript
end toggleVar
BetterTouchTool-Library.applescript
on getTrigger(uid)
BetterTouchTool-Library.applescript
tell application "BetterTouchTool" to set json to get_trigger uid
BetterTouchTool-Library.applescript
return my convertJSONToAS:json isPath:false
BetterTouchTool-Library.applescript
end getTrigger
BetterTouchTool-Library.applescript
on convertJSONToAS:jsonStringOrPath isPath:isPath
BetterTouchTool-Library.applescript
if isPath then -- read file as data
BetterTouchTool-Library.applescript
set theData to ca's NSData's dataWithContentsOfFile:jsonStringOrPath
BetterTouchTool-Library.applescript
else -- it's a string, convert to data
BetterTouchTool-Library.applescript
set aString to NSString's stringWithString:jsonStringOrPath
BetterTouchTool-Library.applescript
set theData to aString's dataUsingEncoding:(ca's NSUTF8StringEncoding)
BetterTouchTool-Library.applescript
set {theThing, theError} to NSJSONSerialization's JSONObjectWithData:theData options:0 |error|:(reference)
BetterTouchTool-Library.applescript
if theThing is missing value then error (theError's localizedDescription() as text) number -10000
BetterTouchTool-Library.applescript
set listOfThing to ca's NSArray's arrayWithObject:theThing
BetterTouchTool-Library.applescript
return item 1 of (theThing as list)
BetterTouchTool-Library.applescript
end convertJSONToAS:isPath:
BetterTouchTool-Library.applescript
on toJSON(str)
BetterTouchTool-Library.applescript
set {theData, theError} to NSJSONSerialization's dataWithJSONObject:str options:0 |error|:(reference)
BetterTouchTool-Library.applescript
if theData is missing value then error (theError's localizedDescription() as text) number -10000
BetterTouchTool-Library.applescript
set someString to NSString's alloc()'s initWithData:theData encoding:(ca's NSUTF8StringEncoding)
BetterTouchTool-Library.applescript
return someString as text
BetterTouchTool-Library.applescript
end toJSON
BetterTouchTool-Library.applescript
on recordFromLabels:labels andValues:values
BetterTouchTool-Library.applescript
set theResult to ca's NSDictionary's dictionaryWithObjects:values forKeys:labels
BetterTouchTool-Library.applescript
return theResult as record
BetterTouchTool-Library.applescript
end recordFromLabels:andValues:
BetterTouchTool-Library.applescript
on setValue:val forKey:_key inRecord:rec
BetterTouchTool-Library.applescript
set theDict to ca's NSMutableDictionary's dictionaryWithDictionary:rec
BetterTouchTool-Library.applescript
theDict's setValue:val forKey:_key
BetterTouchTool-Library.applescript
end setValue:forKey:inRecord:
BetterTouchTool-Library.applescript
property NSString : class "NSString"
open_bbedit_selection_with_terminal.applescript
property NSCharacterSet : class "NSCharacterSet"
open_bbedit_selection_with_terminal.applescript
open_bbedit_selection_with_terminal.applescript
on getNormalizedSelection()
open_bbedit_selection_with_terminal.applescript
tell first document of first window
open_bbedit_selection_with_terminal.applescript
set vSelection to (properties of selection of its window) as record
open_bbedit_selection_with_terminal.applescript
set vContents to (contents of vSelection) as string
open_bbedit_selection_with_terminal.applescript
set vLength to (length of vSelection) as integer
open_bbedit_selection_with_terminal.applescript
set vCharacterOffset to (characterOffset of vSelection) as integer
open_bbedit_selection_with_terminal.applescript
set vStartLine to (startLine of vSelection) as integer
open_bbedit_selection_with_terminal.applescript
set vEndLine to (endLine of vSelection) as integer
open_bbedit_selection_with_terminal.applescript
set vStartColumn to (startColumn of vSelection) as integer
open_bbedit_selection_with_terminal.applescript
set vEndColumn to (endColumn of vSelection) as integer
open_bbedit_selection_with_terminal.applescript
set vStartDisplayLine to (startDisplayLine of vSelection) as integer
open_bbedit_selection_with_terminal.applescript
set vEndDisplayLine to (endDisplayLine of vSelection) as integer
open_bbedit_selection_with_terminal.applescript
set vContainer to container of vSelection
open_bbedit_selection_with_terminal.applescript
set vSelectionSpecifier to selection of its window
open_bbedit_selection_with_terminal.applescript
set vSelectionClass to class of (selection of its window)
open_bbedit_selection_with_terminal.applescript
if vSelectionClass is insertion point then
open_bbedit_selection_with_terminal.applescript
set vRunsCount to 0
open_bbedit_selection_with_terminal.applescript
else if vSelectionClass is character then
open_bbedit_selection_with_terminal.applescript
set vRunsCount to 1
open_bbedit_selection_with_terminal.applescript
else if vSelectionClass is text then
open_bbedit_selection_with_terminal.applescript
set vRunsCount to length of (vSelectionSpecifier as list)
open_bbedit_selection_with_terminal.applescript
error "Unsupported class of selection: '" & vSelectionClass & "'."
open_bbedit_selection_with_terminal.applescript
return {contents:vContents, length:vLength, characterOffset:vCharacterOffset, startLine:vStartLine, endLine:vEndLine, startColumn:vStartColumn, endColumn:vEndColumn, startDisplayLine:vStartDisplayLine, endDisplayLine:vEndDisplayLine, container:vContainer, specifier:vSelectionSpecifier, class:vSelectionClass, runsCount:vRunsCount}
open_bbedit_selection_with_terminal.applescript
on error aMessage
open_bbedit_selection_with_terminal.applescript
display dialog aMessage
open_bbedit_selection_with_terminal.applescript
end getNormalizedSelection
open_bbedit_selection_with_terminal.applescript
on runInTerminal(aCommand)
open_bbedit_selection_with_terminal.applescript
tell selected tab of first window
open_bbedit_selection_with_terminal.applescript
set vTab to do script (aCommand) in it
open_bbedit_selection_with_terminal.applescript
end runInTerminal
open_bbedit_selection_with_terminal.applescript
on trim(aString)
open_bbedit_selection_with_terminal.applescript
set vString to aString as string
open_bbedit_selection_with_terminal.applescript
set vNSString to NSString's stringWithString:vString
open_bbedit_selection_with_terminal.applescript
set vCharacterSet to NSCharacterSet's whitespaceCharacterSet
open_bbedit_selection_with_terminal.applescript
set vNSString to vNSString's stringByTrimmingCharactersInSet:vCharacterSet
open_bbedit_selection_with_terminal.applescript
return vNSString as string
open_bbedit_selection_with_terminal.applescript
end trim
open_bbedit_selection_with_terminal.applescript
on escapePath(aString)
open_bbedit_selection_with_terminal.applescript
set vNSString to vNSString's stringByReplacingOccurrencesOfString:" " withString:"\\ "
open_bbedit_selection_with_terminal.applescript
end escapePath
open_bbedit_selection_with_terminal.applescript
set vSelection to my getNormalizedSelection()
open_bbedit_selection_with_terminal.applescript
set vRunsCount to runsCount of vSelection
open_bbedit_selection_with_terminal.applescript
set vCharacterOffset to characterOffset of vSelection
open_bbedit_selection_with_terminal.applescript
set vStartLine to startLine of vSelection
open_bbedit_selection_with_terminal.applescript
set vStartColumn to startColumn of vSelection
open_bbedit_selection_with_terminal.applescript
if vRunsCount = 0 then -- Nothing selected.
open_bbedit_selection_with_terminal.applescript
set vLine to contents of its line vStartLine
open_bbedit_selection_with_terminal.applescript
set vLineLength to (length of vLine) as integer
open_bbedit_selection_with_terminal.applescript
tell AppleScript -- Use AppleScript's text vocabulary to process string.
open_bbedit_selection_with_terminal.applescript
set vEndColumn to vStartColumn - 1
open_bbedit_selection_with_terminal.applescript
repeat while ((character vEndColumn of vLine) is not in {space, tab}) and (vStartColumn ≤ vLineLength)
open_bbedit_selection_with_terminal.applescript
set vEndColumn to vEndColumn + 1
open_bbedit_selection_with_terminal.applescript
set vLineHead to my trim(texts 1 thru vEndColumn of vLine)
open_bbedit_selection_with_terminal.applescript
set vDelimiters to AppleScript's text item delimiters
open_bbedit_selection_with_terminal.applescript