mirror of
https://github.com/qvacua/vimr.git
synced 2024-12-25 23:02:35 +03:00
Extend a bit the min. example
This commit is contained in:
parent
f388524ef9
commit
81e4bc8d42
@ -4,11 +4,24 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import Cocoa
|
import Cocoa
|
||||||
|
import RxSwift
|
||||||
|
|
||||||
@NSApplicationMain
|
@NSApplicationMain
|
||||||
class AppDelegate: NSObject, NSApplicationDelegate {
|
class AppDelegate: NSObject, NSApplicationDelegate {
|
||||||
|
|
||||||
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
func applicationDidFinishLaunching(_ aNotification: Notification) {}
|
||||||
// Insert code here to initialize your application
|
|
||||||
|
func applicationShouldTerminate(
|
||||||
|
_: NSApplication
|
||||||
|
) -> NSApplication.TerminateReply {
|
||||||
|
|
||||||
|
let docs = NSDocumentController.shared.documents
|
||||||
|
if docs.isEmpty { return .terminateNow }
|
||||||
|
|
||||||
|
try? Completable
|
||||||
|
.concat(docs.compactMap { ($0 as? Document)?.quitWithoutSaving() })
|
||||||
|
.wait()
|
||||||
|
|
||||||
|
return .terminateNow
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,12 +12,12 @@
|
|||||||
</connections>
|
</connections>
|
||||||
</customObject>
|
</customObject>
|
||||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||||
<customObject id="-3" userLabel="Application"/>
|
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||||
<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="xOd-HO-29H" userLabel="Window">
|
<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="min-nvim-demo-doc-window" animationBehavior="default" id="xOd-HO-29H" userLabel="Window">
|
||||||
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
|
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
|
||||||
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
|
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
|
||||||
<rect key="contentRect" x="133" y="235" width="507" height="413"/>
|
<rect key="contentRect" x="133" y="235" width="507" height="413"/>
|
||||||
<rect key="screenRect" x="0.0" y="0.0" width="2880" height="1597"/>
|
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/>
|
||||||
<value key="minSize" type="size" width="94" height="86"/>
|
<value key="minSize" type="size" width="94" height="86"/>
|
||||||
<view key="contentView" id="gIp-Ho-8D9">
|
<view key="contentView" id="gIp-Ho-8D9">
|
||||||
<rect key="frame" x="0.0" y="0.0" width="507" height="413"/>
|
<rect key="frame" x="0.0" y="0.0" width="507" height="413"/>
|
||||||
|
@ -9,55 +9,59 @@ import PureLayout
|
|||||||
import RxSwift
|
import RxSwift
|
||||||
|
|
||||||
class Document: NSDocument, NSWindowDelegate {
|
class Document: NSDocument, NSWindowDelegate {
|
||||||
|
|
||||||
private var nvimView = NvimView(forAutoLayout: ())
|
private var nvimView = NvimView(forAutoLayout: ())
|
||||||
private let disposeBag = DisposeBag()
|
private let disposeBag = DisposeBag()
|
||||||
|
|
||||||
override init() {
|
override init() {
|
||||||
super.init()
|
super.init()
|
||||||
|
|
||||||
nvimView
|
nvimView
|
||||||
.events
|
.events
|
||||||
.subscribe(onNext: { event in
|
.subscribe(onNext: { event in
|
||||||
switch event {
|
switch event {
|
||||||
|
|
||||||
case .neoVimStopped: DispatchQueue.main.async { self.close() }
|
case .neoVimStopped: DispatchQueue.main.async { self.close() }
|
||||||
|
|
||||||
default: Swift.print("Event received: \(event)")
|
default: Swift.print("Event received: \(event)")
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.disposed(by: self.disposeBag)
|
.disposed(by: self.disposeBag)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func quitWithoutSaving() -> Completable {
|
||||||
|
return self.nvimView.quitNeoVimWithoutSaving()
|
||||||
|
}
|
||||||
|
|
||||||
func windowShouldClose(_ sender: NSWindow) -> Bool {
|
func windowShouldClose(_ sender: NSWindow) -> Bool {
|
||||||
try? self.nvimView.quitNeoVimWithoutSaving().wait()
|
try? self.quitWithoutSaving().wait()
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
override func windowControllerDidLoadNib(_ windowController: NSWindowController) {
|
override func windowControllerDidLoadNib(_ windowController: NSWindowController) {
|
||||||
super.windowControllerDidLoadNib(windowController)
|
super.windowControllerDidLoadNib(windowController)
|
||||||
|
|
||||||
let window = windowController.window!
|
let window = windowController.window!
|
||||||
window.delegate = self
|
window.delegate = self
|
||||||
|
|
||||||
let view = window.contentView!
|
let view = window.contentView!
|
||||||
view.addSubview(self.nvimView)
|
view.addSubview(self.nvimView)
|
||||||
self.nvimView.autoPinEdgesToSuperviewEdges()
|
self.nvimView.autoPinEdgesToSuperviewEdges()
|
||||||
}
|
}
|
||||||
|
|
||||||
override var windowNibName: NSNib.Name? {
|
override var windowNibName: NSNib.Name? {
|
||||||
// Returns the nib file name of the document
|
// Returns the nib file name of the document
|
||||||
// If you need to use a subclass of NSWindowController or if your document supports multiple NSWindowControllers, you should remove this property and override -makeWindowControllers instead.
|
// If you need to use a subclass of NSWindowController or if your document supports multiple NSWindowControllers, you should remove this property and override -makeWindowControllers instead.
|
||||||
return NSNib.Name("Document")
|
return NSNib.Name("Document")
|
||||||
}
|
}
|
||||||
|
|
||||||
override func data(ofType typeName: String) throws -> Data {
|
override func data(ofType typeName: String) throws -> Data {
|
||||||
// Insert code here to write your document to data of the specified type, throwing an error in case of failure.
|
// Insert code here to write your document to data of the specified type, throwing an error in case of failure.
|
||||||
// Alternatively, you could remove this method and override fileWrapper(ofType:), write(to:ofType:), or write(to:ofType:for:originalContentsURL:) instead.
|
// Alternatively, you could remove this method and override fileWrapper(ofType:), write(to:ofType:), or write(to:ofType:for:originalContentsURL:) instead.
|
||||||
throw NSError(domain: NSOSStatusErrorDomain, code: unimpErr, userInfo: nil)
|
throw NSError(domain: NSOSStatusErrorDomain, code: unimpErr, userInfo: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
override func read(from data: Data, ofType typeName: String) throws {
|
override func read(from data: Data, ofType typeName: String) throws {
|
||||||
// Insert code here to read your document from the given data of the specified type, throwing an error in case of failure.
|
// Insert code here to read your document from the given data of the specified type, throwing an error in case of failure.
|
||||||
// Alternatively, you could remove this method and override read(from:ofType:) instead.
|
// Alternatively, you could remove this method and override read(from:ofType:) instead.
|
||||||
|
@ -61,12 +61,8 @@
|
|||||||
4B02260C224AAEA80052362B /* PureLayout.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 4B022603224AAE770052362B /* PureLayout.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
4B02260C224AAEA80052362B /* PureLayout.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 4B022603224AAE770052362B /* PureLayout.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||||
4B02260D224AAEA80052362B /* Socket.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BEBC239215FD19C007113C4 /* Socket.framework */; };
|
4B02260D224AAEA80052362B /* Socket.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BEBC239215FD19C007113C4 /* Socket.framework */; };
|
||||||
4B02260E224AAEA80052362B /* Socket.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 4BEBC239215FD19C007113C4 /* Socket.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
4B02260E224AAEA80052362B /* Socket.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 4BEBC239215FD19C007113C4 /* Socket.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||||
4B02260F224AAEA80052362B /* RxNeovimApi.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B17E548209E3E4100265C1D /* RxNeovimApi.framework */; };
|
|
||||||
4B022610224AAEA80052362B /* RxNeovimApi.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 4B17E548209E3E4100265C1D /* RxNeovimApi.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
|
||||||
4B022613224AAEA80052362B /* MessagePack.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BB1F5CA209740E900EC394A /* MessagePack.framework */; };
|
4B022613224AAEA80052362B /* MessagePack.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BB1F5CA209740E900EC394A /* MessagePack.framework */; };
|
||||||
4B022614224AAEA80052362B /* MessagePack.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 4BB1F5CA209740E900EC394A /* MessagePack.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
4B022614224AAEA80052362B /* MessagePack.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 4BB1F5CA209740E900EC394A /* MessagePack.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||||
4B022615224AAEA80052362B /* RxMsgpackRpc.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BB1F5C8209740E400EC394A /* RxMsgpackRpc.framework */; };
|
|
||||||
4B022616224AAEA80052362B /* RxMsgpackRpc.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 4BB1F5C8209740E400EC394A /* RxMsgpackRpc.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
|
||||||
4B022617224AAEA80052362B /* RxSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BC5B0421FE551DF0071D64F /* RxSwift.framework */; };
|
4B022617224AAEA80052362B /* RxSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BC5B0421FE551DF0071D64F /* RxSwift.framework */; };
|
||||||
4B022618224AAEA80052362B /* RxSwift.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 4BC5B0421FE551DF0071D64F /* RxSwift.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
4B022618224AAEA80052362B /* RxSwift.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 4BC5B0421FE551DF0071D64F /* RxSwift.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||||
4B02261B224AAF1C0052362B /* RxSwiftCommons.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B02261A224AAF1B0052362B /* RxSwiftCommons.swift */; };
|
4B02261B224AAF1C0052362B /* RxSwiftCommons.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B02261A224AAF1B0052362B /* RxSwiftCommons.swift */; };
|
||||||
@ -188,9 +184,7 @@
|
|||||||
4B02260C224AAEA80052362B /* PureLayout.framework in Embed Frameworks */,
|
4B02260C224AAEA80052362B /* PureLayout.framework in Embed Frameworks */,
|
||||||
4B022614224AAEA80052362B /* MessagePack.framework in Embed Frameworks */,
|
4B022614224AAEA80052362B /* MessagePack.framework in Embed Frameworks */,
|
||||||
4B022618224AAEA80052362B /* RxSwift.framework in Embed Frameworks */,
|
4B022618224AAEA80052362B /* RxSwift.framework in Embed Frameworks */,
|
||||||
4B022616224AAEA80052362B /* RxMsgpackRpc.framework in Embed Frameworks */,
|
|
||||||
4B022608224AAEA80052362B /* NvimView.framework in Embed Frameworks */,
|
4B022608224AAEA80052362B /* NvimView.framework in Embed Frameworks */,
|
||||||
4B022610224AAEA80052362B /* RxNeovimApi.framework in Embed Frameworks */,
|
|
||||||
);
|
);
|
||||||
name = "Embed Frameworks";
|
name = "Embed Frameworks";
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
@ -354,9 +348,7 @@
|
|||||||
4B02260B224AAEA80052362B /* PureLayout.framework in Frameworks */,
|
4B02260B224AAEA80052362B /* PureLayout.framework in Frameworks */,
|
||||||
4B022613224AAEA80052362B /* MessagePack.framework in Frameworks */,
|
4B022613224AAEA80052362B /* MessagePack.framework in Frameworks */,
|
||||||
4B022617224AAEA80052362B /* RxSwift.framework in Frameworks */,
|
4B022617224AAEA80052362B /* RxSwift.framework in Frameworks */,
|
||||||
4B022615224AAEA80052362B /* RxMsgpackRpc.framework in Frameworks */,
|
|
||||||
4B022607224AAEA80052362B /* NvimView.framework in Frameworks */,
|
4B022607224AAEA80052362B /* NvimView.framework in Frameworks */,
|
||||||
4B02260F224AAEA80052362B /* RxNeovimApi.framework in Frameworks */,
|
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Scheme
|
||||||
|
version = "1.3">
|
||||||
|
<BuildAction>
|
||||||
|
<BuildActionEntries>
|
||||||
|
<BuildActionEntry
|
||||||
|
buildForRunning = "YES">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "4B0225EF224AAE260052362B"
|
||||||
|
BuildableName = "MinimalNvimViewDemo.app"
|
||||||
|
BlueprintName = "MinimalNvimViewDemo"
|
||||||
|
ReferencedContainer = "container:NvimView.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildActionEntry>
|
||||||
|
</BuildActionEntries>
|
||||||
|
</BuildAction>
|
||||||
|
<LaunchAction
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
allowLocationSimulation = "YES">
|
||||||
|
<BuildableProductRunnable>
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "4B0225EF224AAE260052362B"
|
||||||
|
BuildableName = "MinimalNvimViewDemo.app"
|
||||||
|
BlueprintName = "MinimalNvimViewDemo"
|
||||||
|
ReferencedContainer = "container:NvimView.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildableProductRunnable>
|
||||||
|
<LocationScenarioReference
|
||||||
|
identifier = "com.apple.dt.IDEFoundation.CurrentLocationScenarioIdentifier"
|
||||||
|
referenceType = "1">
|
||||||
|
</LocationScenarioReference>
|
||||||
|
</LaunchAction>
|
||||||
|
</Scheme>
|
Loading…
Reference in New Issue
Block a user