Query now highlights in the list.
This commit is contained in:
@@ -3,7 +3,7 @@ import AppKit
|
|||||||
class ProgramTableRowView: NSTableRowView {
|
class ProgramTableRowView: NSTableRowView {
|
||||||
override func drawSelection(in dirtyRect: NSRect) {
|
override func drawSelection(in dirtyRect: NSRect) {
|
||||||
if self.selectionHighlightStyle != .none {
|
if self.selectionHighlightStyle != .none {
|
||||||
let selectionColor = NSColor.systemBlue
|
let selectionColor = NSColor.controlAccentColor
|
||||||
selectionColor.setFill()
|
selectionColor.setFill()
|
||||||
self.bounds.fill()
|
self.bounds.fill()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -311,10 +311,7 @@ class SearchViewController: NSViewController, NSTextFieldDelegate,
|
|||||||
programsTableView.scrollRowToVisible(programsTableViewSelection)
|
programsTableView.scrollRowToVisible(programsTableViewSelection)
|
||||||
|
|
||||||
if programsList.count > 0 {
|
if programsList.count > 0 {
|
||||||
let program = programsList[0]
|
appIconImage.image = programsList[0].img
|
||||||
let url = URL(fileURLWithPath: program.path)
|
|
||||||
.appendingPathComponent(program.name+program.ext)
|
|
||||||
appIconImage.image = NSWorkspace.shared.icon(forFile: url.path)
|
|
||||||
} else {
|
} else {
|
||||||
appIconImage.image =
|
appIconImage.image =
|
||||||
NSWorkspace.shared.icon(forFile: Bundle.main.bundlePath)
|
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
|
// PERF: This is very slow, even with 10 items on the list! It has
|
||||||
// to be the image of concern. UIKit has reusable cells,
|
// to be the image of concern. UIKit has reusable cells,
|
||||||
// is that possible? Or is fetching an image is slow?
|
// 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.progPathLabel.stringValue = program.path
|
||||||
cell.appIconImage.image = program.img
|
cell.appIconImage.image = program.img
|
||||||
cell.id = row
|
cell.id = row
|
||||||
|
|||||||
Reference in New Issue
Block a user