mirror of
https://github.com/qvacua/vimr.git
synced 2024-12-25 14:52:19 +03:00
Add stub select handler
This commit is contained in:
parent
f0c9ff4a93
commit
728974601a
@ -27,7 +27,7 @@ public class NvimView: NSView,
|
||||
|
||||
public static let minLinespacing = (0.5).cgf
|
||||
public static let maxLinespacing = 8.cgf
|
||||
|
||||
|
||||
public let usesCustomTabBar: Bool
|
||||
public let tabBar: TabBar<TabEntry>?
|
||||
|
||||
@ -155,12 +155,17 @@ public class NvimView: NSView,
|
||||
)
|
||||
|
||||
self.sourceFileUrls = config.sourceFiles
|
||||
|
||||
|
||||
self.usesCustomTabBar = config.usesCustomTabBar
|
||||
if self.usesCustomTabBar { self.tabBar = TabBar<TabEntry>(withTheme: .default) }
|
||||
else { self.tabBar = nil }
|
||||
|
||||
super.init(frame: .zero)
|
||||
|
||||
self.tabBar?.selectHandler = { [weak self] (index, tabEntry) in
|
||||
Swift.print("tab \(index): \(tabEntry) selected")
|
||||
}
|
||||
|
||||
self.bridge.consumer = self
|
||||
self.registerForDraggedTypes([NSPasteboard.PasteboardType(String(kUTTypeFileURL))])
|
||||
|
||||
|
@ -13,6 +13,7 @@ public protocol TabRepresentative: Hashable {
|
||||
|
||||
public class TabBar<Entry: TabRepresentative>: NSView {
|
||||
public var theme: Theme { self._theme }
|
||||
public var selectHandler: ((Int, Entry) -> Void)?
|
||||
|
||||
public init(withTheme theme: Theme) {
|
||||
self._theme = theme
|
||||
@ -59,9 +60,9 @@ public class TabBar<Entry: TabRepresentative>: NSView {
|
||||
}
|
||||
|
||||
extension TabBar {
|
||||
func select(tab _: Tab<Entry>) {
|
||||
// self.stackView.arrangedSubviews.forEach { ($0 as? Tab<Entry>)?.isSelected = false }
|
||||
// tab.isSelected = true
|
||||
func select(tab: Tab<Entry>) {
|
||||
guard let index = self.tabs.firstIndex(where: { $0 == tab }) else { return }
|
||||
self.selectHandler?(index, tab.tabRepresentative)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user