Query now highlights in the list.

This commit is contained in:
2025-01-08 16:52:32 -08:00
parent 8b0e42a7c8
commit c15691a1a1
2 changed files with 14 additions and 6 deletions

View File

@@ -3,7 +3,7 @@ import AppKit
class ProgramTableRowView: NSTableRowView {
override func drawSelection(in dirtyRect: NSRect) {
if self.selectionHighlightStyle != .none {
let selectionColor = NSColor.systemBlue
let selectionColor = NSColor.controlAccentColor
selectionColor.setFill()
self.bounds.fill()
}

View File

@@ -311,10 +311,7 @@ class SearchViewController: NSViewController, NSTextFieldDelegate,
programsTableView.scrollRowToVisible(programsTableViewSelection)
if programsList.count > 0 {
let program = programsList[0]
let url = URL(fileURLWithPath: program.path)
.appendingPathComponent(program.name+program.ext)
appIconImage.image = NSWorkspace.shared.icon(forFile: url.path)
appIconImage.image = programsList[0].img
} else {
appIconImage.image =
NSWorkspace.shared.icon(forFile: Bundle.main.bundlePath)
@@ -370,7 +367,18 @@ class SearchViewController: NSViewController, NSTextFieldDelegate,
// PERF: This is very slow, even with 10 items on the list! It has
// to be the image of concern. UIKit has reusable cells,
// is that possible? Or is fetching an image is slow?
cell.titleField.stringValue = program.name + program.ext
// searchInput.stringValue
let app = program.name + program.ext
let rangeToHighlight =
(app.lowercased() as NSString)
.range(of: searchInput.stringValue.lowercased())
let attributedString = NSMutableAttributedString(string: app)
attributedString.addAttributes(
[.backgroundColor: NSColor.systemOrange],
range: rangeToHighlight)
cell.titleField.attributedStringValue = attributedString
cell.progPathLabel.stringValue = program.path
cell.appIconImage.image = program.img
cell.id = row