Skip to content

A fast file manager for Windows and macOS that never freezes: tabs, dual panes, archives as folders, Quick Look-style previews. A File Explorer and Finder alternative written in Rust.

Mac: pane paths in dual pane, and a choice for closing the last tab

gelenmedyaa7dc420a1373
diff --git a/macos/Sources/RustyFiles/BrowserWindowController.swift b/macos/Sources/RustyFiles/BrowserWindowController.swift
index 79162aff..7d59bd88 100644
--- a/macos/Sources/RustyFiles/BrowserWindowController.swift
+++ b/macos/Sources/RustyFiles/BrowserWindowController.swift
@@ -159,6 +159,7 @@ final class BrowserWindowController: NSWindowController, NSWindowDelegate, NSMen
private let sidebar = SidebarView()
private let handle = SidebarResizeHandle()
private let paneDivider = PaneDivider()
+ private let leftPath = PanePathStrip(), rightPath = PanePathStrip()
private var lastPaneArea: NSRect = .zero
/// The left pane's share of a dual pane's width, kept across starts (0.5: half each).
private var paneShare: CGFloat = {
@@ -227,7 +228,9 @@ final class BrowserWindowController: NSWindowController, NSWindowDelegate, NSMen
window.contentView = frame
applyMaterial()
applyScale()
- [sidebar, handle, leftList.card, rightList.card, paneDivider, navBar, titleBar].forEach(root.addSubview)
+ [sidebar, handle, leftList.card, rightList.card, leftPath, rightPath, paneDivider, navBar, titleBar].forEach(root.addSubview)
+ leftPath.onClick = { [weak self] in self?.focusPane(right: false) }
+ rightPath.onClick = { [weak self] in self?.focusPane(right: true) }
paneDivider.onDrag = { [weak self] x in
guard let self else { return }
if let x, self.lastPaneArea.width > 0 {
@@ -278,11 +281,24 @@ final class BrowserWindowController: NSWindowController, NSWindowDelegate, NSMen
let area = NSRect(x: left, y: top, width: b.width - left - Metrics.cardRightMargin, height: b.height - top - Metrics.bottomSpacer)
rightList.card.isHidden = !dual
paneDivider.isHidden = !dual
+ let paths = dual && AppSettings.dualPanePaths
+ leftPath.isHidden = !paths
+ rightPath.isHidden = !paths
if dual {
// two cards side by side, 6 apart (workspace.rs dual pane); the gap moves the split
let w = floor(min(max((area.width - 6) * paneShare, 240), area.width - 6 - 240))
- leftList.card.frame = NSRect(x: area.minX, y: area.minY, width: w, height: area.height)
- rightList.card.frame = NSRect(x: area.minX + w + 6, y: area.minY, width: area.width - w - 6, height: area.height)
+ let strip: CGFloat = paths ? 22 : 0
+ let cards = NSRect(x: area.minX, y: area.minY + strip, width: area.width, height: area.height - strip)
+ leftList.card.frame = NSRect(x: cards.minX, y: cards.minY, width: w, height: cards.height)
+ rightList.card.frame = NSRect(x: cards.minX + w + 6, y: cards.minY, width: cards.width - w - 6, height: cards.height)
+ leftPath.frame = NSRect(x: area.minX, y: area.minY, width: w, height: strip)
+ rightPath.frame = NSRect(x: area.minX + w + 6, y: area.minY, width: area.width - w - 6, height: strip)
+ if paths, let r = tabs[active].right {
+ leftPath.text = Self.paneTitle(tabs[active])
+ rightPath.text = Self.paneTitle(r)
+ leftPath.active = !rightActive
+ rightPath.active = rightActive
+ }
paneDivider.frame = NSRect(x: area.minX + w, y: area.minY, width: 6, height: area.height)
lastPaneArea = area
} else {
@@ -318,6 +334,7 @@ final class BrowserWindowController: NSWindowController, NSWindowDelegate, NSMen
if key == "material" || key == "theme" { applyMaterial() }
if key == "interfacePercent" { applyScale() }
if key == "tabPath" { refreshTabs() }
+ if key == "dualPanePaths" { root.needsLayout = true }
if key == "compactWindow" {
[leftList, rightList].forEach { $0.card.applyCompact(); $0.card.needsLayout = true }
root.needsLayout = true
@@ -491,6 +508,11 @@ final class BrowserWindowController: NSWindowController, NSWindowDelegate, NSMen
// MARK: dual pane
+ /// What a pane's path strip says: the folder's path (~ for the home folder), else the page's title.
+ private static func paneTitle(_ t: BrowserTab) -> String {
+ t.url.isFileURL && !t.isPage ? (t.url.path as NSString).abbreviatingWithTildeInPath : t.info.title
+ }
+
/// The pane `right` takes the keyboard: the address bar, Back, Up and the menus follow it.
private func focusPane(right: Bool) {
guard dual, right != rightActive else { return }
@@ -820,6 +842,15 @@ final class BrowserWindowController: NSWindowController, NSWindowDelegate, NSMen
private func closeTab(at i: Int) {
guard tabs.indices.contains(i) else { return }
if tabs.count == 1 {
+ // Settings › Closing the last tab: the window stays and the tab goes Home
+ if AppSettings.lastTabClose == "home" {
+ if !tabs[0].isHome || tabs[0].right != nil {
+ closedTabs.append(tabs[0].url)
+ if tabs[0].right != nil { toggleDualPane(nil) }
+ navigate(to: BrowserTab.homeURL)
+ }
+ return
+ }
window?.performClose(nil)
return
}
@@ -1111,6 +1142,7 @@ final class BrowserWindowController: NSWindowController, NSWindowDelegate, NSMen
}
private func updateChrome() {
+ if dual && AppSettings.dualPanePaths { root.needsLayout = true }
navBar.back.isEnabled = !tab.back.isEmpty
navBar.forward.isEnabled = !tab.forward.isEmpty
navBar.up.isEnabled = !tab.isHome && (tab.isSettings || tab.tagName != nil || tab.smartFolder != nil || tab.searchSpec != nil || tab.diskRoot != nil || tab.url.path != "/")
diff --git a/macos/Sources/RustyFiles/SettingsBehaviour.swift b/macos/Sources/RustyFiles/SettingsBehaviour.swift
index 1b200a93..58f965e6 100644
--- a/macos/Sources/RustyFiles/SettingsBehaviour.swift
+++ b/macos/Sources/RustyFiles/SettingsBehaviour.swift
@@ -48,6 +48,19 @@ extension AppSettings {
set { store(newValue, "newTabOpens") }
}
+ /// Dual pane: each pane shows its own folder's path above it.
+ static var dualPanePaths: Bool {
+ get { flag("dualPanePaths", true) }
+ set { store(newValue, "dualPanePaths") }
+ }
+
+ /// Closing the window's only tab: "window" closes the window, "home" keeps it and goes Home
+ /// (Windows' last_tab_close, issue 456).
+ static var lastTabClose: String {
+ get { d.string(forKey: "lastTabClose") ?? "window" }
+ set { store(newValue, "lastTabClose") }
+ }
+
/// A tab opened from a menu ("Open in new tab") becomes the active one.
static var switchToNewTab: Bool {
get { flag("switchToNewTab", true) }
diff --git a/macos/Sources/RustyFiles/SettingsView.swift b/macos/Sources/RustyFiles/SettingsView.swift
index a8fd58af..f7e254e9 100644
--- a/macos/Sources/RustyFiles/SettingsView.swift
+++ b/macos/Sources/RustyFiles/SettingsView.swift
@@ -269,6 +269,14 @@ extension SettingsContent {
control: .choice(
options: [("home", String(localized: "Home")), ("current", String(localized: "The current folder"))],
get: { AppSettings.newTabOpens }, set: { AppSettings.newTabOpens = $0 })),
+ .card(
+ title: String(localized: "Dual pane: each pane shows its path"), detail: nil, icon: "columns-2",
+ control: .toggle(get: { AppSettings.dualPanePaths }, set: { AppSettings.dualPanePaths = $0 })),
+ .card(
+ title: String(localized: "Closing the last tab"), detail: nil, icon: "square-x",
+ control: .choice(
+ options: [("window", String(localized: "Closes the window")), ("home", String(localized: "Keeps the window and shows Home"))],
+ get: { AppSettings.lastTabClose }, set: { AppSettings.lastTabClose = $0 })),
.card(
title: String(localized: "Always switch to a newly opened tab"), detail: nil, icon: "arrow-right-left",
control: .toggle(get: { AppSettings.switchToNewTab }, set: { AppSettings.switchToNewTab = $0 })),
diff --git a/macos/Sources/RustyFiles/Sidebar.swift b/macos/Sources/RustyFiles/Sidebar.swift
index c2f0d8df..90ab283b 100644
--- a/macos/Sources/RustyFiles/Sidebar.swift
+++ b/macos/Sources/RustyFiles/Sidebar.swift
@@ -668,3 +668,27 @@ final class SidebarResizeHandle: FlippedView {
override func mouseUp(with event: NSEvent) { start = nil }
}
+
+/// Dual pane: the pane's own folder above it (Windows' dual_pane_paths, discussion 732). The
+/// address bar shows only the active pane's; this says where the other one is. A click on it
+/// makes that pane the active one.
+@MainActor
+final class PanePathStrip: FlippedView {
+ var text = "" { didSet { if text != oldValue { needsDisplay = true; toolTip = text } } }
+ var active = false { didSet { if active != oldValue { needsDisplay = true } } }
+ var onClick: (() -> Void)?
+
+ override var mouseDownCanMoveWindow: Bool { false }
+ override func mouseDown(with event: NSEvent) { onClick?() }
+
+ override func draw(_ dirtyRect: NSRect) {
+ let p = Palette.of(self)
+ let style = NSMutableParagraphStyle()
+ style.lineBreakMode = .byTruncatingHead
+ let attrs: [NSAttributedString.Key: Any] = [
+ .font: Metrics.textXs, .foregroundColor: active ? p.text : p.textSecondary, .paragraphStyle: style,
+ ]
+ let h = (text as NSString).size(withAttributes: attrs).height
+ (text as NSString).draw(in: NSRect(x: 12, y: (bounds.height - h) / 2, width: bounds.width - 24, height: h), withAttributes: attrs)
+ }
+}