From ee621b7993a92861cea8d5a5483e3f5518dbec47 Mon Sep 17 00:00:00 2001 From: jess Date: Mon, 6 Apr 2026 12:02:09 -0700 Subject: [PATCH] work in progress on table indicators --- src/EditorView.swift | 64 +++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/src/EditorView.swift b/src/EditorView.swift index 0f54977..febb037 100644 --- a/src/EditorView.swift +++ b/src/EditorView.swift @@ -333,7 +333,7 @@ class MarkdownTableView: NSView, NSTextFieldDelegate { private let indicatorRowHeight: CGFloat = 20 private let indicatorColWidth: CGFloat = 30 - private var indicatorsVisible = false + private var indicatorsVisible = true private var indicatorContainer: NSView? private var focusMonitor: Any? @@ -408,8 +408,8 @@ class MarkdownTableView: NSView, NSTextFieldDelegate { let colCount = table.headers.count guard colCount > 0 else { return } let th = totalHeight - let ox = indicatorOffset - let oy = indicatorTopOffset + let ox = indicatorColWidth + let oy = indicatorRowHeight let gridWidth = columnX(for: colCount) + 1 let fullWidth = gridWidth + ox let fullHeight = th + oy @@ -467,9 +467,7 @@ class MarkdownTableView: NSView, NSTextFieldDelegate { addSubview(line) } - if indicatorsVisible { - buildIndicators() - } + buildIndicators() } private func makeCell(text: String, frame: NSRect, isHeader: Bool, row: Int, col: Int) -> NSTextField { @@ -510,14 +508,6 @@ class MarkdownTableView: NSView, NSTextFieldDelegate { // MARK: - Indicators - private var indicatorOffset: CGFloat { - indicatorsVisible ? indicatorColWidth : 0 - } - - private var indicatorTopOffset: CGFloat { - indicatorsVisible ? indicatorRowHeight : 0 - } - private func buildIndicators() { indicatorContainer?.removeFromSuperview() @@ -529,10 +519,10 @@ class MarkdownTableView: NSView, NSTextFieldDelegate { let colCount = table.headers.count let totalRows = 1 + table.rows.count - let th = totalHeight + indicatorTopOffset + let topY = totalHeight + indicatorRowHeight let indicatorBg = Theme.current.surface0 - let corner = NSView(frame: NSRect(x: 0, y: th - indicatorRowHeight, width: indicatorColWidth, height: indicatorRowHeight)) + let corner = NSView(frame: NSRect(x: 0, y: topY - indicatorRowHeight, width: indicatorColWidth, height: indicatorRowHeight)) corner.wantsLayer = true corner.layer?.backgroundColor = indicatorBg.cgColor container.addSubview(corner) @@ -543,14 +533,14 @@ class MarkdownTableView: NSView, NSTextFieldDelegate { label.font = NSFont.systemFont(ofSize: 10, weight: .medium) label.textColor = Theme.current.overlay2 label.alignment = .center - label.frame = NSRect(x: x, y: th - indicatorRowHeight, width: columnWidths[col], height: indicatorRowHeight) + label.frame = NSRect(x: x, y: topY - indicatorRowHeight, width: columnWidths[col], height: indicatorRowHeight) label.wantsLayer = true label.layer?.backgroundColor = indicatorBg.cgColor container.addSubview(label) } for row in 0.. Int? { - let ox = indicatorOffset let colCount = table.headers.count for i in 1.. Int? { - let oy = indicatorTopOffset let totalRows = 1 + table.rows.count for i in 0..