diff --git a/writeas.xcodeproj/project.pbxproj b/writeas.xcodeproj/project.pbxproj index 5680293..ce9eba5 100644 --- a/writeas.xcodeproj/project.pbxproj +++ b/writeas.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + C98EE9AC1F29532F002F646E /* writeas in Resources */ = {isa = PBXBuildFile; fileRef = C98EE9AB1F29532F002F646E /* writeas */; }; C99B910D1C33841E00A91990 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C99B910C1C33841E00A91990 /* AppDelegate.swift */; }; C99B910F1C33841E00A91990 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C99B910E1C33841E00A91990 /* ViewController.swift */; }; C99B91111C33841F00A91990 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C99B91101C33841F00A91990 /* Assets.xcassets */; }; @@ -14,6 +15,7 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + C98EE9AB1F29532F002F646E /* writeas */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; path = writeas; sourceTree = ""; }; C99B91091C33841E00A91990 /* Write.as.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Write.as.app; sourceTree = BUILT_PRODUCTS_DIR; }; C99B910C1C33841E00A91990 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; C99B910E1C33841E00A91990 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; @@ -52,6 +54,7 @@ C99B910B1C33841E00A91990 /* writeas */ = { isa = PBXGroup; children = ( + C98EE9AB1F29532F002F646E /* writeas */, C99B910C1C33841E00A91990 /* AppDelegate.swift */, C99B910E1C33841E00A91990 /* ViewController.swift */, C99B91101C33841F00A91990 /* Assets.xcassets */, @@ -122,6 +125,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + C98EE9AC1F29532F002F646E /* writeas in Resources */, C99B91111C33841F00A91990 /* Assets.xcassets in Resources */, C99B91141C33841F00A91990 /* Main.storyboard in Resources */, ); diff --git a/writeas/AppDelegate.swift b/writeas/AppDelegate.swift index 49b2eef..9599da9 100644 --- a/writeas/AppDelegate.swift +++ b/writeas/AppDelegate.swift @@ -42,5 +42,9 @@ class AppDelegate: NSObject, NSApplicationDelegate { @IBAction func saveDocument(_ sender: AnyObject) { vc?.saveDocument() } + + @IBAction func publishDoc(_ sender: Any) { + vc?.publish() + } } diff --git a/writeas/Base.lproj/Main.storyboard b/writeas/Base.lproj/Main.storyboard index 3ff0d6a..0c4ff9e 100644 --- a/writeas/Base.lproj/Main.storyboard +++ b/writeas/Base.lproj/Main.storyboard @@ -65,6 +65,15 @@ + + + +DQ + + + + + diff --git a/writeas/ViewController.swift b/writeas/ViewController.swift index 7cc9f05..a166bdb 100644 --- a/writeas/ViewController.swift +++ b/writeas/ViewController.swift @@ -87,6 +87,19 @@ class ViewController: NSViewController, NSTextViewDelegate { } } + func publish() { + saveDocument() + + let task = Process() + task.launchPath = Bundle.main.executablePath! + "/../../Resources/writeas" + let pipe = Pipe() + task.standardInput = pipe + task.launch() + let fh: FileHandle = pipe.fileHandleForWriting + fh.write(writerText.textStorage!.string.data(using: .utf8)!) + fh.closeFile() + } + func toggle(isNight: Bool) { let darkBG = NSColor(red:0.13, green:0.13, blue:0.13, alpha:1.0) if isNight { diff --git a/writeas/writeas b/writeas/writeas new file mode 100755 index 0000000..780525f Binary files /dev/null and b/writeas/writeas differ