mirror of
https://github.com/bitsycore/Allofit.git
synced 2026-10-06 21:07:27 +00:00
- Status bar: last search time, memory footprint, CPU use (highlighted when busy) and role, with a tooltip for peak memory, threads, index age, cache size and roots. Sampled every 2 s, redraws only the status bar; match count and search time live in a separate object so the table isn't re-rendered. - Background throttling: file changes are collected longer and open results refresh less often when Allofit isn't focused or no window is visible; sampling pauses when hidden. Showing a window applies pending changes at once. - Settings > Performance: the update delays (focused / another app focused / no window) and result refresh intervals, with an estimate of how soon a changed file appears and Restore Defaults. Defaults 2 s / 15 s / 1 min and 1 s / 5 s. - Drag rows as file URLs (like Finder) instead of a plain link, so browsers upload the file instead of navigating to it. - Canonicalize roots with realpath: roots under /tmp, /var or /etc never matched their own entries because Foundation strips /private.
52 lines
1.6 KiB
Swift
52 lines
1.6 KiB
Swift
import Foundation
|
|
|
|
// Formatters bundles the byte-count and date formatting used by both
|
|
// the Table's columns and the right-hand preview pane footer. Keeping
|
|
// the formatter instances cached at file scope avoids reconstructing
|
|
// them per row render, which would be expensive at thousands of rows.
|
|
enum Formatters {
|
|
|
|
// file-size formatter (decimal units, like Finder)
|
|
private static let kSizeFormatter: ByteCountFormatter = {
|
|
let vF = ByteCountFormatter()
|
|
vF.countStyle = .file
|
|
return vF
|
|
}()
|
|
|
|
// human-friendly byte count, e.g. "1.2 MB"
|
|
static func size(bytes inBytes: Int64) -> String {
|
|
return kSizeFormatter.string(fromByteCount: inBytes)
|
|
}
|
|
|
|
// memory formatter (binary units, like Activity Monitor)
|
|
private static let kMemoryFormatter: ByteCountFormatter = {
|
|
let vF = ByteCountFormatter()
|
|
vF.countStyle = .memory
|
|
return vF
|
|
}()
|
|
|
|
// memory amount, e.g. "312 MB" (binary units, like Activity Monitor)
|
|
static func memory(bytes inBytes: UInt64) -> String {
|
|
return kMemoryFormatter.string(fromByteCount: Int64(clamping: inBytes))
|
|
}
|
|
|
|
// same as size(bytes:), but "-" for zero / unknown (missing files)
|
|
static func sizeOrDash(bytes inBytes: Int64) -> String {
|
|
return inBytes <= 0 ? "-" : size(bytes: inBytes)
|
|
}
|
|
|
|
// short date + short time, in the user's locale
|
|
private static let kDateFormatter: DateFormatter = {
|
|
let vF = DateFormatter()
|
|
vF.dateStyle = .short
|
|
vF.timeStyle = .short
|
|
return vF
|
|
}()
|
|
|
|
// short date+time, with "-" for sentinel "no date" values
|
|
static func date(_ inDate: Date) -> String {
|
|
if inDate.timeIntervalSince1970 < 1 { return "-" }
|
|
return kDateFormatter.string(from: inDate)
|
|
}
|
|
}
|