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:
parent
6c7ff8a300
commit
baaf920089
@ -46,6 +46,11 @@ extension NvimView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum Warning {
|
||||||
|
case cannotCloseLastTab
|
||||||
|
case noWriteSinceLastChange
|
||||||
|
}
|
||||||
|
|
||||||
public enum Event {
|
public enum Event {
|
||||||
|
|
||||||
case neoVimStopped
|
case neoVimStopped
|
||||||
@ -68,6 +73,8 @@ extension NvimView {
|
|||||||
case rpcEvent([MessagePack.MessagePackValue])
|
case rpcEvent([MessagePack.MessagePackValue])
|
||||||
case rpcEventSubscribed
|
case rpcEventSubscribed
|
||||||
|
|
||||||
|
case warning(Warning)
|
||||||
|
|
||||||
case initVimError
|
case initVimError
|
||||||
|
|
||||||
// FIXME: maybe do onError()?
|
// FIXME: maybe do onError()?
|
||||||
|
@ -183,8 +183,12 @@ public class NvimView: NSView,
|
|||||||
array[0].uint64Value == RxNeovimApi.Error.exceptionRawValue,
|
array[0].uint64Value == RxNeovimApi.Error.exceptionRawValue,
|
||||||
let errorMsg = array[1].stringValue else { return }
|
let errorMsg = array[1].stringValue else { return }
|
||||||
|
|
||||||
if errorMsg.contains("Vim(tabclose):E784") { Swift.print("cannot close last tab page!") }
|
if errorMsg.contains("Vim(tabclose):E784") {
|
||||||
if errorMsg.starts(with: "Vim(tabclose):E37") { Swift.print("no write!") }
|
self?.eventsSubject.onNext(.warning(.cannotCloseLastTab))
|
||||||
|
}
|
||||||
|
if errorMsg.starts(with: "Vim(tabclose):E37") {
|
||||||
|
self?.eventsSubject.onNext(.warning(.noWriteSinceLastChange))
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
self?.log.debug("???: This should not happen")
|
self?.log.debug("???: This should not happen")
|
||||||
|
@ -310,6 +310,8 @@ class MainWindow: NSObject,
|
|||||||
|
|
||||||
case let .rpcEvent(params): self?.rpcEventAction(params: params)
|
case let .rpcEvent(params): self?.rpcEventAction(params: params)
|
||||||
|
|
||||||
|
case let .warning(warning): self?.show(warning: warning)
|
||||||
|
|
||||||
case .rpcEventSubscribed: break
|
case .rpcEventSubscribed: break
|
||||||
}
|
}
|
||||||
}, onError: { error in
|
}, onError: { error in
|
||||||
@ -476,15 +478,15 @@ class MainWindow: NSObject,
|
|||||||
private func set(tabsThemeWith _: Theme) {
|
private func set(tabsThemeWith _: Theme) {
|
||||||
var tabsTheme = Tabs.Theme.default
|
var tabsTheme = Tabs.Theme.default
|
||||||
|
|
||||||
tabsTheme.foregroundColor = theme.foreground
|
tabsTheme.foregroundColor = self.theme.foreground
|
||||||
tabsTheme.backgroundColor = theme.background
|
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.selectedForegroundColor = self.theme.highlightForeground
|
||||||
tabsTheme.selectedBackgroundColor = theme.highlightBackground
|
tabsTheme.selectedBackgroundColor = self.theme.highlightBackground
|
||||||
|
|
||||||
tabsTheme.tabSelectedIndicatorColor = theme.highlightForeground
|
tabsTheme.tabSelectedIndicatorColor = self.theme.highlightForeground
|
||||||
|
|
||||||
self.neoVimView.tabBar?.update(theme: tabsTheme)
|
self.neoVimView.tabBar?.update(theme: tabsTheme)
|
||||||
}
|
}
|
||||||
@ -581,4 +583,8 @@ class MainWindow: NSObject,
|
|||||||
|
|
||||||
NSUserNotificationCenter.default.deliver(notification)
|
NSUserNotificationCenter.default.deliver(notification)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func show(warning: NvimView.Warning) {
|
||||||
|
Swift.print(warning)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user