mirror of
https://github.com/qvacua/vimr.git
synced 2024-12-26 07:13:24 +03:00
Forward warning to main window
This commit is contained in:
parent
6c7ff8a300
commit
baaf920089
@ -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()?
|
||||
|
@ -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")
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user