1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-11-24 03:25:03 +03:00

Adapt NvimView demo app to custom tabs

This commit is contained in:
Tae Won Ha 2021-01-09 16:59:24 +09:00
parent b396942c21
commit f06fd354da
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44
2 changed files with 15 additions and 14 deletions

View File

@ -4,15 +4,12 @@
*/
import Cocoa
import RxSwift
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
func applicationDidFinishLaunching(_: Notification) {}
func applicationShouldTerminate(
_: NSApplication
) -> NSApplication.TerminateReply {
func applicationShouldTerminate(_: NSApplication) -> NSApplication.TerminateReply {
NSDocumentController.shared
.documents
.compactMap { $0 as? Document }

View File

@ -26,7 +26,6 @@ class Document: NSDocument, NSWindowDelegate {
.subscribe(onNext: { event in
switch event {
case .neoVimStopped: self.close()
default: break
}
})
@ -50,26 +49,31 @@ class Document: NSDocument, NSWindowDelegate {
window.delegate = self
let view = window.contentView!
view.addSubview(self.nvimView)
self.nvimView.autoPinEdgesToSuperviewEdges()
let nvimView = self.nvimView
// We know that we use custom tabs.
let tabBar = nvimView.tabBar!
view.addSubview(tabBar)
view.addSubview(nvimView)
tabBar.autoPinEdge(toSuperviewEdge: .left)
tabBar.autoPinEdge(toSuperviewEdge: .top)
tabBar.autoPinEdge(toSuperviewEdge: .right)
nvimView.autoPinEdge(.top, to: .bottom, of: tabBar)
nvimView.autoPinEdge(toSuperviewEdge: .left)
nvimView.autoPinEdge(toSuperviewEdge: .right)
nvimView.autoPinEdge(toSuperviewEdge: .bottom)
}
override var windowNibName: NSNib.Name? {
// 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.
NSNib.Name("Document")
}
override func data(ofType _: String) throws -> Data {
// 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.
throw NSError(domain: NSOSStatusErrorDomain, code: unimpErr, userInfo: nil)
}
override func read(from _: Data, ofType _: String) throws {
// 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.
// If you do, you should also override isEntireFileLoaded to return false if the contents are lazily loaded.
throw NSError(domain: NSOSStatusErrorDomain, code: unimpErr, userInfo: nil)
}
}