Skip to content

armgit / cra

Public Imported from GitHub
0

The open-source Arc replacement for macOS. Spaces, pinned tabs, split view, Little Windows and Arc's shortcuts on Chromium, with your Arc sidebar imported in one go.

Arc parity: Open in Split View and Add Split View on the sidebar's tab menu

Victor56a52324b630
diff --git a/Sources/Cra/UI/Sidebar/List/SidebarMenus.swift b/Sources/Cra/UI/Sidebar/List/SidebarMenus.swift
index d5c0510..d3a7e6d 100644
--- a/Sources/Cra/UI/Sidebar/List/SidebarMenus.swift
+++ b/Sources/Cra/UI/Sidebar/List/SidebarMenus.swift
@@ -78,6 +78,12 @@ enum SidebarMenus {
add(menu, action: "renameTab", "Rename…") { ui.renamingID = id }
if item.title != nil { add(menu, "Use Page Title") { store.rename(id, to: nil) } }
if m.pinned, tab.liveItemURL == nil { pinnedURLItems(menu, id, navigatedAway: m.navigatedAway, store: store, actions: actions) }
+ // Arc: "Add Split View" on the open tab, "Open in Split View" on any other.
+ if store.isSelected(id, window: ui.windowID) {
+ add(menu, action: "addSplitView", "Add Split View") { actions.performAction("addSplitView") }
+ } else if store.selectedTabID(window: ui.windowID) != nil, store.spaceID(ofItem: id) == store.focusedSpaceID(window: ui.windowID) {
+ add(menu, "Open in Split View") { actions.performAction("openInSplit:\(id.uuidString)") }
+ }
add(menu, action: "duplicateTab", "Duplicate") { _ = store.duplicateTab(id) }
add(menu, action: "copyURL", "Copy Link") { copy(CleanURL.withoutTrackers(tab.url)) }
add(menu, action: "muteTab", tab.muted ? "Unmute" : "Mute") {
diff --git a/Sources/Cra/UI/Windows/MainWindowController.swift b/Sources/Cra/UI/Windows/MainWindowController.swift
index 07236de..c935e1a 100644
--- a/Sources/Cra/UI/Windows/MainWindowController.swift
+++ b/Sources/Cra/UI/Windows/MainWindowController.swift
@@ -380,7 +380,9 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserM
}
}
sidebarActions.performAction = { [weak self] id in
- if id.hasPrefix("muteTab:"), let uuid = UUID(uuidString: String(id.dropFirst(8))) {
+ if id.hasPrefix("openInSplit:"), let uuid = UUID(uuidString: String(id.dropFirst(12))) {
+ self?.openTabInSplit(uuid)
+ } else if id.hasPrefix("muteTab:"), let uuid = UUID(uuidString: String(id.dropFirst(8))) {
let muted = self?.store.item(uuid)?.tab?.muted ?? false
self?.app.runtime(for: uuid)?.browser.setAudioMuted(muted)
} else {
@@ -575,6 +577,17 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserM
openCommandBar(.editURL)
}
+ /// Arc's "Open in Split View" on a sidebar tab: that tab joins the open one in a split, as the
+ /// command bar's split row does with a tab it lists.
+ func openTabInSplit(_ id: UUID) {
+ guard let current = selectedTabID, current != id, store.item(current)?.isEmptyTab == false else { return }
+ if store.paneTabIDs(for: current).contains(id) { store.selectTab(id, window: windowID); return }
+ guard store.paneTabIDs(for: current).count < 4 else { showToast("Cannot Add New Pane"); return }
+ let split = store.splitContaining(current).map { sp in store.addToSplit(sp.id, tabID: id, at: nil); return store.item(sp.id) }
+ ?? store.createSplit(with: [current, id], at: current)
+ store.selectTab(split.flatMap { store.paneID(for: id, in: $0) } ?? id, window: windowID)
+ }
+
/// Arc's "Close this Split Pane" (⌃⇧-): the pane's tab closes like any tab;
/// the split keeps the other panes. A pinned split's pane leaves it (closing it
/// would only unload the whole split).
diff --git a/docs/arc-parity.md b/docs/arc-parity.md
index f3ad604..d03eeca 100644
--- a/docs/arc-parity.md
+++ b/docs/arc-parity.md
@@ -73,8 +73,8 @@ gains "New Profile".
| Where | Arc items Cra lacks |
|---|---|
-| Today tab | Share ▸, Change Icon…, Open in Split View, Archive Tabs Below |
-| Pinned tab | Share ▸, Change Icon…, Edit Pinned Page ▸ (submenu), Add Split View, Remove Pin |
+| Today tab | Share ▸, Change Icon… (Open in Split View and Archive Tabs Below done) |
+| Pinned tab | Share ▸, Change Icon…, Edit Pinned Page ▸ (Cra lists them flat on purpose, PR #55), Remove Pin (Add Split View done) |
| Space header / empty sidebar | Share Space… (*skip*), New Folder, Manage Spaces…, Delete Space (check order) |
| Toolbar address | Share ▸ (in the Site Control Center), Disable Shared Quotes (arc.net); the rest done |
| Library button | Show media ▸ Documents, Desktop, Screenshots, Arc Captures, Downloads |
@@ -114,6 +114,7 @@ in this sweep (Essential Shortcuts window, Library pages).
menu's Capture…, Capture Full Page, Manage Extensions… and Hide Toolbar.
- Settings ▸ Tabs ▸ Archive Little Windows after (1 hour, 6 hours, 12 hours); Settings ▸ Profiles ▸
Your Data and Settings (Chromium's privacy, passwords, cards and notifications pages per profile).
+- Sidebar tab menu: Add Split View on the open tab, Open in Split View on any other.
## Left for later, and why