1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-26 23:36:08 +03:00

Forward warning to main window

This commit is contained in:
Tae Won Ha 2020-12-09 22:14:51 +01:00
parent 6c7ff8a300
commit baaf920089
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44
3 changed files with 25 additions and 8 deletions

View File

@ -46,6 +46,11 @@ extension NvimView {
}
}
public enum Warning {
case cannotCloseLastTab
case noWriteSinceLastChange
}
public enum Event {
case neoVimStopped
@ -68,6 +73,8 @@ extension NvimView {
case rpcEvent([MessagePack.MessagePackValue])
case rpcEventSubscribed
case warning(Warning)
case initVimError
// FIXME: maybe do onError()?

View File

@ -183,8 +183,12 @@ public class NvimView: NSView,
array[0].uint64Value == RxNeovimApi.Error.exceptionRawValue,
let errorMsg = array[1].stringValue else { return }
if errorMsg.contains("Vim(tabclose):E784") { Swift.print("cannot close last tab page!") }
if errorMsg.starts(with: "Vim(tabclose):E37") { Swift.print("no write!") }
if errorMsg.contains("Vim(tabclose):E784") {
self?.eventsSubject.onNext(.warning(.cannotCloseLastTab))
}
if errorMsg.starts(with: "Vim(tabclose):E37") {
self?.eventsSubject.onNext(.warning(.noWriteSinceLastChange))
}
default:
self?.log.debug("???: This should not happen")

View File

@ -310,6 +310,8 @@ class MainWindow: NSObject,
case let .rpcEvent(params): self?.rpcEventAction(params: params)
case let .warning(warning): self?.show(warning: warning)
case .rpcEventSubscribed: break
}
}, onError: { error in
@ -476,15 +478,15 @@ class MainWindow: NSObject,
private func set(tabsThemeWith _: Theme) {
var tabsTheme = Tabs.Theme.default
tabsTheme.foregroundColor = theme.foreground
tabsTheme.backgroundColor = theme.background
tabsTheme.foregroundColor = self.theme.foreground
tabsTheme.backgroundColor = self.theme.background
tabsTheme.separatorColor = theme.background.brightening(by: 0.75)
tabsTheme.separatorColor = self.theme.background.brightening(by: 0.75)
tabsTheme.selectedForegroundColor = theme.highlightForeground
tabsTheme.selectedBackgroundColor = theme.highlightBackground
tabsTheme.selectedForegroundColor = self.theme.highlightForeground
tabsTheme.selectedBackgroundColor = self.theme.highlightBackground
tabsTheme.tabSelectedIndicatorColor = theme.highlightForeground
tabsTheme.tabSelectedIndicatorColor = self.theme.highlightForeground
self.neoVimView.tabBar?.update(theme: tabsTheme)
}
@ -581,4 +583,8 @@ class MainWindow: NSObject,
NSUserNotificationCenter.default.deliver(notification)
}
private func show(warning: NvimView.Warning) {
Swift.print(warning)
}
}