This repository has been archived by the owner on Nov 13, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
15 changed files
with
119 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
2 changes: 2 additions & 0 deletions
2
GlanceTests/TestFiles/apple-script/example-apple-script.applescript
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- This is a comment | ||
display alert "Alert!" |
Binary file not shown.
31 changes: 31 additions & 0 deletions
31
GlanceTests/TestFiles/apple-script/example-apple-script.scptd/Contents/Info.plist
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleIdentifier</key> | ||
<string>com.apple.ScriptEditor.id.example-applescript</string> | ||
<key>CFBundleName</key> | ||
<string>Untitled</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>WindowState</key> | ||
<dict> | ||
<key>bundleDividerCollapsed</key> | ||
<true/> | ||
<key>bundlePositionOfDivider</key> | ||
<real>0.0</real> | ||
<key>dividerCollapsed</key> | ||
<false/> | ||
<key>eventLogLevel</key> | ||
<integer>2</integer> | ||
<key>name</key> | ||
<string>ScriptWindowState</string> | ||
<key>positionOfDivider</key> | ||
<real>421</real> | ||
<key>savedFrame</key> | ||
<string>69 157 700 672 0 0 1440 877 </string> | ||
<key>selectedTab</key> | ||
<string>result</string> | ||
</dict> | ||
</dict> | ||
</plist> |
Binary file added
BIN
+550 Bytes
...ts/TestFiles/apple-script/example-apple-script.scptd/Contents/Resources/Scripts/main.scpt
Binary file not shown.
5 changes: 5 additions & 0 deletions
5
...Files/apple-script/example-apple-script.scptd/Contents/Resources/description.rtfd/TXT.rtf
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{\rtf1\ansi\ansicpg1252\cocoartf2512 | ||
\cocoatextscaling0\cocoaplatform0{\fonttbl} | ||
{\colortbl;\red255\green255\blue255;} | ||
{\*\expandedcolortbl;;} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// This is a comment | ||
const app = Application.currentApplication(); | ||
app.includeStandardAdditions = true; | ||
app.displayAlert("Alert!"); |
Binary file not shown.
31 changes: 31 additions & 0 deletions
31
GlanceTests/TestFiles/apple-script/example-jxa.scptd/Contents/Info.plist
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleIdentifier</key> | ||
<string>com.apple.ScriptEditor.id.example-jxa</string> | ||
<key>CFBundleName</key> | ||
<string>example-jxa</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>WindowState</key> | ||
<dict> | ||
<key>bundleDividerCollapsed</key> | ||
<true/> | ||
<key>bundlePositionOfDivider</key> | ||
<real>0.0</real> | ||
<key>dividerCollapsed</key> | ||
<false/> | ||
<key>eventLogLevel</key> | ||
<integer>2</integer> | ||
<key>name</key> | ||
<string>ScriptWindowState</string> | ||
<key>positionOfDivider</key> | ||
<real>395</real> | ||
<key>savedFrame</key> | ||
<string>69 157 700 672 0 0 1440 877 </string> | ||
<key>selectedTab</key> | ||
<string>result</string> | ||
</dict> | ||
</dict> | ||
</plist> |
Binary file added
BIN
+216 Bytes
GlanceTests/TestFiles/apple-script/example-jxa.scptd/Contents/Resources/Scripts/main.scpt
Binary file not shown.
5 changes: 5 additions & 0 deletions
5
...ests/TestFiles/apple-script/example-jxa.scptd/Contents/Resources/description.rtfd/TXT.rtf
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{\rtf1\ansi\ansicpg1252\cocoartf2512 | ||
\cocoatextscaling0\cocoaplatform0{\fonttbl} | ||
{\colortbl;\red255\green255\blue255;} | ||
{\*\expandedcolortbl;;} | ||
} |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import SwiftExec | ||
|
||
/// View controller for previewing AppleScript files: | ||
/// | ||
/// - `.applescript`: AppleScript text file (can be read directly) | ||
/// - `.scpt`: AppleScript binary (needs to be decompiled) | ||
/// - `.scptd`: AppleScript bundle (includes a binary, which needs to be decompiled) | ||
/// | ||
/// The class extends `CodePreview` so syntax highlighting is applied after the script's content has | ||
/// been determined. | ||
/// | ||
// TODO: Scripts can also be written in JavaScript (JXA). This language needs to be detected and | ||
// passed to Chroma to get correct syntax highlighting. | ||
class AppleScriptPreview: CodePreview { | ||
override func getSource(file: File) throws -> String { | ||
if file.url.pathExtension == "scpt" || file.url.pathExtension == "scptd" { | ||
let result = try! exec( | ||
program: "/usr/bin/osadecompile", | ||
arguments: [file.path] | ||
) | ||
return result.stdout ?? "" | ||
} | ||
return try! file.read() | ||
} | ||
} |
This file contains 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