1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-24 22:33:52 +03:00

Use user notification for init errors

This commit is contained in:
Tae Won Ha 2017-12-17 22:20:35 +01:00
parent 9c751df034
commit 2745bd9457
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44
2 changed files with 16 additions and 7 deletions

View File

@ -34,6 +34,12 @@ extension NvimView {
self.resizeNeoVimUi(to: self.bounds.size)
}
public func userNotificationCenter(_ center: NSUserNotificationCenter,
shouldPresent notification: NSUserNotification) -> Bool {
return true
}
func discreteSize(size: CGSize) -> Size {
return Size(width: Int(floor(size.width / self.cellSize.width)),
height: Int(floor(size.height / self.cellSize.height)))
@ -71,12 +77,14 @@ extension NvimView {
self.logger.fault("There was an error launching neovim.")
DispatchQueue.main.async {
let alert = NSAlert()
alert.alertStyle = .warning
alert.messageText = "Error during initialization"
alert.informativeText = "There was an error during the initialization of NeoVim. " +
"Use :messages to view the error messages."
alert.runModal()
let notification = NSUserNotification()
notification.identifier = self.uuid
notification.title = "Error during initialization"
notification.informativeText = "There was an error during the initialization of NeoVim. " +
"Use :messages to view the error messages."
NSUserNotificationCenter.default.delegate = self
NSUserNotificationCenter.default.deliver(notification)
}
}
}

View File

@ -10,7 +10,8 @@ import RxSwift
public class NvimView: NSView,
NvimUiBridgeProtocol,
NSUserInterfaceValidations,
NSTextInputClient {
NSTextInputClient,
NSUserNotificationCenterDelegate {
// MARK: - Public
public struct Config {