oficina / sheets Public

Clone
git clone https://amadan.net/oficina/sheets

Plain git — no account needed to clone.

Download

Download this file

1#if os(macOS)
2import AppKit
3
4extension SheetModel {
5 /// Fits the loaded grid (the same visible rows used by the editor).
6 func fitColumn(_ column: Int) async {
7 guard (0..<cols).contains(column), mayWrite, !busy, !hasUnconfirmedChanges else { return }
8 var width: CGFloat = 40
9 for (point, cell) in cells where point.c == column {
10 let style = styles[cell.f ?? ""]
11 var font = NSFont.systemFont(ofSize: 13, weight: style?.b == true ? .bold : .regular)
12 if style?.i == true { font = NSFontManager.shared.convert(font, toHaveTrait: .italicFontMask) }
13 width = max(width, (cell.display as NSString).size(withAttributes: [.font: font]).width + 14)
14 }
15 await resize(axis: "col", size: min(1000, Int(ceil(width))), index: column)
16 }
17}
18#endif
19