Skip to content

Commit 0e740d5

Browse files
committed
Merge branch 'chrome-tabs'
2 parents eade4d1 + e411d3e commit 0e740d5

4 files changed

Lines changed: 242 additions & 7 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ DerivedData/
1010

1111
# Build artifacts
1212
FFWF.app/
13+
*.dmg

Sources/FFWF/ContentView.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ struct ContentView: View {
5353
let item = filteredItems[selectedIndex].window
5454
let title = item.title.isEmpty ? item.ownerName : item.title
5555
let announcement: String
56-
if item.isTerminalTab {
56+
if item.isTab {
5757
let tabPrefix: String
58-
if let tabIndex = item.terminalTabIndex {
58+
if let tabIndex = item.tabIndex {
5959
tabPrefix = "tab \(tabIndex)"
6060
} else {
6161
tabPrefix = "tab"
@@ -309,12 +309,12 @@ struct WindowRow: View {
309309
var accessibilityDescription: String {
310310
let title = window.title.isEmpty ? window.ownerName : window.title
311311
let app = window.title.isEmpty ? "" : ", \(window.ownerName)"
312-
let role = window.isTerminalTab ? "Tab" : "Window"
312+
let role = window.isTab ? "Tab" : "Window"
313313
let position = "\(role) \(index) of \(total)"
314314
let state = isSelected ? ", selected" : ""
315-
if window.isTerminalTab {
315+
if window.isTab {
316316
let tabPrefix: String
317-
if let tabIndex = window.terminalTabIndex {
317+
if let tabIndex = window.tabIndex {
318318
tabPrefix = "tab \(tabIndex)"
319319
} else {
320320
tabPrefix = "tab"
@@ -337,7 +337,7 @@ struct WindowRow: View {
337337

338338
VStack(alignment: .leading, spacing: 2) {
339339
HStack(spacing: 8) {
340-
if window.isTerminalTab {
340+
if window.isTab {
341341
Text("TAB")
342342
.font(.system(size: 10, weight: .semibold))
343343
.foregroundColor(.accentColor)
@@ -371,7 +371,7 @@ struct WindowRow: View {
371371
.cornerRadius(4)
372372
.accessibilityElement(children: .combine)
373373
.accessibilityLabel(accessibilityDescription)
374-
.accessibilityHint(window.isTerminalTab ? "Press Enter to switch to this tab" : "Press Enter to switch to this window")
374+
.accessibilityHint(window.isTab ? "Press Enter to switch to this tab" : "Press Enter to switch to this window")
375375
.accessibilityAddTraits(isSelected ? [.isSelected, .isButton] : [.isButton])
376376
}
377377
}

Sources/FFWF/WindowInfo.swift

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import AppKit
44
enum WindowKind: Hashable {
55
case window
66
case terminalTab(windowTitle: String, tabTitle: String, tabIndex: Int)
7+
case chromeTab(windowTitle: String, tabTitle: String, tabIndex: Int)
78
}
89

910
struct WindowInfo: Identifiable, Hashable {
@@ -79,19 +80,44 @@ struct WindowInfo: Identifiable, Hashable {
7980
return "\(ownerName): \(title)"
8081
}
8182

83+
var isTab: Bool {
84+
switch kind {
85+
case .terminalTab, .chromeTab:
86+
return true
87+
case .window:
88+
return false
89+
}
90+
}
91+
8292
var isTerminalTab: Bool {
8393
if case .terminalTab = kind {
8494
return true
8595
}
8696
return false
8797
}
8898

99+
var isChromeTab: Bool {
100+
if case .chromeTab = kind {
101+
return true
102+
}
103+
return false
104+
}
105+
89106
var terminalTabIndex: Int? {
90107
if case .terminalTab(_, _, let tabIndex) = kind {
91108
return tabIndex
92109
}
93110
return nil
94111
}
112+
113+
var tabIndex: Int? {
114+
switch kind {
115+
case .terminalTab(_, _, let tabIndex), .chromeTab(_, _, let tabIndex):
116+
return tabIndex
117+
case .window:
118+
return nil
119+
}
120+
}
95121
}
96122

97123
struct ScoredWindow: Identifiable {

0 commit comments

Comments
 (0)