|
@@ -17,6 +17,7 @@ extension KMNSearchKey.caseSensitive {
|
|
|
}
|
|
|
|
|
|
enum KMNBotaSearchType: Int {
|
|
|
+ case none = 0
|
|
|
case search = 1
|
|
|
case replace = 2
|
|
|
}
|
|
@@ -28,9 +29,7 @@ enum KMNBotaSearchType: Int {
|
|
|
class KMBotaSearchViewController: KMNBotaBaseViewController {
|
|
|
@IBOutlet weak var searchField: NSSearchField!
|
|
|
@IBOutlet weak var segmentedControl: KMSegmentedControl!
|
|
|
-
|
|
|
@IBOutlet weak var topView: NSBox!
|
|
|
-
|
|
|
@IBOutlet weak var topHeightConst: NSLayoutConstraint!
|
|
|
|
|
|
var contentView: NSView? {
|
|
@@ -62,7 +61,6 @@ class KMBotaSearchViewController: KMNBotaBaseViewController {
|
|
|
|
|
|
private var emptyView_: ComponentEmpty = {
|
|
|
let view = ComponentEmpty()
|
|
|
- // , image: NSImage(named: "KMImageNameOutlineEmpty")
|
|
|
view.properties = ComponentEmptyProperty(emptyType: .noSearch, state: .normal, text: KMLocalizedString("No Results"), subText: KMLocalizedString(""))
|
|
|
return view
|
|
|
}()
|
|
@@ -81,12 +79,7 @@ class KMBotaSearchViewController: KMNBotaBaseViewController {
|
|
|
}
|
|
|
|
|
|
private var datas: [Any] = []
|
|
|
-
|
|
|
- deinit {
|
|
|
- KMPrint("KMBotaSearchViewController deinit.")
|
|
|
-
|
|
|
- NotificationCenter.default.removeObserver(self)
|
|
|
- }
|
|
|
+ private var searchResultIndex_: Int = -1
|
|
|
|
|
|
override func loadView() {
|
|
|
super.loadView()
|
|
@@ -121,10 +114,7 @@ class KMBotaSearchViewController: KMNBotaBaseViewController {
|
|
|
guard let string = info?[.newKey] as? String else {
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
- let isCase = KMDataManager.ud_bool(forKey: KMNSearchKey.caseSensitive.botaSearch)
|
|
|
- let isWholeWord = KMDataManager.ud_bool(forKey: KMNSearchKey.wholeWords.botaSearch)
|
|
|
- handdler.search(keyword: string, isCase: isCase, isWholeWord: isWholeWord) { [unowned self] results in
|
|
|
+ self.search(keyword: string) { [unowned self] results in
|
|
|
searchResults = results ?? []
|
|
|
|
|
|
showResult()
|
|
@@ -141,44 +131,8 @@ class KMBotaSearchViewController: KMNBotaBaseViewController {
|
|
|
self.emptySearchLabel.stringValue = KMLocalizedString("")
|
|
|
self.emptySearchLabel.textColor = KMAppearance.Layout.h1Color()
|
|
|
self.emptyBox.fillColor = KMAppearance.Layout.l0Color()
|
|
|
-// self.searchLabel.stringValue = KMLocalizedString("Search")
|
|
|
-// self.searchLabel.textColor = KMAppearance.Layout.h0Color()
|
|
|
-// self.searchTips.stringValue = KMLocalizedString("Search")
|
|
|
-// self.searchTips.textColor = KMAppearance.Layout.h2Color()
|
|
|
-// self.searchResultsLabel.textColor = KMAppearance.Layout.h1Color()
|
|
|
-// self.pageLabel.stringValue = KMLocalizedString("Page")
|
|
|
-// self.pageLabel.textColor = KMAppearance.Layout.h1Color()
|
|
|
-// self.searchResultsView.isHidden = true
|
|
|
-
|
|
|
-// self.searchDomeButton.title = KMLocalizedString("Done")
|
|
|
-// self.searchDomeButton.toolTip = KMLocalizedString("Done")
|
|
|
-// self.searchDomeButton.setTitleColor(KMAppearance.Layout.w0Color())
|
|
|
-// self.searchDomeButton.wantsLayer = true
|
|
|
-// self.searchDomeButton.layer?.backgroundColor = KMAppearance.Interactive.a0Color().cgColor
|
|
|
-// self.searchDomeButton.layer?.cornerRadius = 4.0
|
|
|
- // self.searchDomeButton.hidden = YES;
|
|
|
-
|
|
|
-// self.searchField.wantsLayer = true
|
|
|
- // self.searchField.layer.backgroundColor = [KMAppearance KMColor_Layout_L1].CGColor;
|
|
|
-// self.searchField.layer?.cornerRadius = 1.0
|
|
|
-// self.searchField.layer?.borderWidth = 1.0
|
|
|
-// self.searchField.layer?.borderColor = KMAppearance.Interactive.a0Color().cgColor
|
|
|
-
|
|
|
-// self.searchBox.fillColor = KMAppearance.Interactive.s0Color()
|
|
|
- // self.searchField.hidden = YES;
|
|
|
-// self.searchBox.downCallback = { [unowned self] downEntered, box, _ in
|
|
|
-// if (downEntered) {
|
|
|
-// self.searchField.isHidden = false
|
|
|
-// self.searchDomeButton.isHidden = false
|
|
|
-// self.searchBox.isHidden = true
|
|
|
-// self.searchField.becomeFirstResponder()
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
-// self.searchBox.isHidden = true
|
|
|
|
|
|
contentView = tableView.enclosingScrollView
|
|
|
-
|
|
|
tableView.menuClickedAction = { [unowned self] point in
|
|
|
let idxs = self.tableView.selectedRowIndexes.count
|
|
|
|
|
@@ -188,6 +142,12 @@ class KMBotaSearchViewController: KMNBotaBaseViewController {
|
|
|
return NSMenu()
|
|
|
}
|
|
|
|
|
|
+ let hideNotes = handdler.hideNotes()
|
|
|
+ let allowsNotes = handdler.allowsNotes()
|
|
|
+ if hideNotes || allowsNotes == false {
|
|
|
+ return NSMenu()
|
|
|
+ }
|
|
|
+
|
|
|
guard let model = self.datas[row] as? KMSearchMode else {
|
|
|
return NSMenu()
|
|
|
}
|
|
@@ -218,35 +178,6 @@ class KMBotaSearchViewController: KMNBotaBaseViewController {
|
|
|
self.menuGroupView_?.showWithPoint(CGPoint(x: point.x, y: point.y - viewHeight), relativeTo: self.tableView)
|
|
|
return NSMenu()
|
|
|
}
|
|
|
-
|
|
|
-// var rowIndexes = self.findTableView.selectedRowIndexes
|
|
|
-// let row = self.findTableView.clickedRow
|
|
|
-// if (row != -1) {
|
|
|
-// if rowIndexes.contains(row) == false {
|
|
|
-// rowIndexes = IndexSet(integer: row)
|
|
|
-// }
|
|
|
-//
|
|
|
-// var selections: [CPDFSelection] = []
|
|
|
-// for (i, data) in self.searchResults.enumerated() {
|
|
|
-// if rowIndexes.contains(i) {
|
|
|
-// selections.append(data.selection)
|
|
|
-// }
|
|
|
-// }
|
|
|
-// let hideNotes = self.hideNotes()
|
|
|
-// let allowsNotes = self.allowsNotes()
|
|
|
-// if hideNotes == false && allowsNotes {
|
|
|
-// item = menu.addItem(withTitle: KMLocalizedString("Add New Circle"), action: #selector(addAnnotationsForSelections), target: self, tag: CAnnotationType.circle.rawValue)
|
|
|
-// item?.representedObject = selections
|
|
|
-// item = menu.addItem(withTitle: KMLocalizedString("Add New Rectangle"), action: #selector(addAnnotationsForSelections), target: self, tag: CAnnotationType.square.rawValue)
|
|
|
-// item?.representedObject = selections
|
|
|
-// item = menu.addItem(withTitle: KMLocalizedString("Add New Highlight"), action: #selector(addAnnotationsForSelections), target: self, tag: CAnnotationType.highlight.rawValue)
|
|
|
-// item?.representedObject = selections
|
|
|
-// item = menu.addItem(withTitle: KMLocalizedString("Add New Underline"), action: #selector(addAnnotationsForSelections), target: self, tag: CAnnotationType.underline.rawValue)
|
|
|
-// item?.representedObject = selections
|
|
|
-// item = menu.addItem(withTitle: KMLocalizedString("Add New Strikethrough"), action: #selector(addAnnotationsForSelections), target: self, tag: CAnnotationType.strikeOut.rawValue)
|
|
|
-// item?.representedObject = selections
|
|
|
-// }
|
|
|
-// }
|
|
|
}
|
|
|
|
|
|
override func viewDidLoad() {
|
|
@@ -255,21 +186,12 @@ class KMBotaSearchViewController: KMNBotaBaseViewController {
|
|
|
self.tableView.delegate = self
|
|
|
self.tableView.dataSource = self
|
|
|
self.tableView.botaDelegate = self
|
|
|
-// self.tableView.menu?.delegate = self
|
|
|
-
|
|
|
-// self.mwcFlags.wholeWordSearch = KMDataManager.ud_integer(forKey: SKWholeWordSearchKey)
|
|
|
-// self.mwcFlags.caseInsensitiveSearch = KMDataManager.ud_integer(forKey: SKCaseInsensitiveSearchKey)
|
|
|
-
|
|
|
-// self.tableView.backgroundColor = KMAppearance.Layout.l0Color()
|
|
|
- self.tableView.tableColumn(withIdentifier: kPageColumnId)?.headerCell.title = KMLocalizedString("Page")
|
|
|
}
|
|
|
|
|
|
override func viewDidAppear() {
|
|
|
super.viewDidAppear()
|
|
|
|
|
|
// self.searchField.becomeFirstResponder()
|
|
|
- self.updateViewColor()
|
|
|
- DistributedNotificationCenter.default().addObserver(self, selector: #selector(themeChanged), name: NSApplication.interfaceThemeChangedNotification, object: nil)
|
|
|
}
|
|
|
|
|
|
override func updateUILanguage() {
|
|
@@ -298,14 +220,6 @@ class KMBotaSearchViewController: KMNBotaBaseViewController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- func updateViewColor() {
|
|
|
- if (KMAppearance.isDarkMode()) {
|
|
|
-// self.searchField.layer?.backgroundColor = NSColor(red: 57.0/255.0, green: 60.0/255.0, blue: 62.0/255.0, alpha: 1).cgColor
|
|
|
- } else {
|
|
|
-// self.searchField.layer?.backgroundColor = .white
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
func showSearchView() {
|
|
|
topContentView_?.showSearch()
|
|
|
|
|
@@ -325,6 +239,27 @@ class KMBotaSearchViewController: KMNBotaBaseViewController {
|
|
|
topHeightConst.constant = topContentView_?.fetchContentHeight(type: handdler.type, hasResult: searchResults.isEmpty == false) ?? 0
|
|
|
}
|
|
|
|
|
|
+ func update(keyborad: String?, replaceKey: String?, results: [KMSearchMode]) {
|
|
|
+// searchItemView_.inputValue = keyborad
|
|
|
+// replaceItemView_.inputValue = replaceKey
|
|
|
+//
|
|
|
+// if results.isEmpty == false {
|
|
|
+// handdler.searchResults = results
|
|
|
+// self.currentSel = results.first?.selection
|
|
|
+// if let sel = self.currentSel {
|
|
|
+// self.handdler.showSelection(sel)
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// updateButtonStatus()
|
|
|
+ }
|
|
|
+
|
|
|
+ func search(keyword: String, callback: @escaping (([KMBotaSearchSectionModel]?) -> Void)) {
|
|
|
+ let isCase = KMDataManager.ud_bool(forKey: KMNSearchKey.caseSensitive.botaSearch)
|
|
|
+ let isWholeWord = KMDataManager.ud_bool(forKey: KMNSearchKey.wholeWords.botaSearch)
|
|
|
+ handdler.search(keyword: keyword, isCase: isCase, isWholeWord: isWholeWord, callback: callback)
|
|
|
+ }
|
|
|
+
|
|
|
// MARK: - Group View
|
|
|
|
|
|
func showSearchGroupView(sender: ComponentButton) {
|
|
@@ -372,43 +307,12 @@ class KMBotaSearchViewController: KMNBotaBaseViewController {
|
|
|
searchGroupTarget = sender
|
|
|
}
|
|
|
|
|
|
- @objc func themeChanged(_ notification: NSNotification) {
|
|
|
- DispatchQueue.main.asyncAfter(deadline: .now()+0.3) {
|
|
|
- self.updateViewColor()
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
@IBAction func searchDomeButtonAtion(_ sender: AnyObject) {
|
|
|
self.searchField.isHidden = true
|
|
|
self.searchDomeButton.isHidden = true
|
|
|
self.searchBox.isHidden = false
|
|
|
}
|
|
|
|
|
|
- @objc func toggleWholeWordSearch(_ sender: AnyObject?) {
|
|
|
-// if self.mwcFlags.wholeWordSearch == 1 {
|
|
|
-// self.mwcFlags.wholeWordSearch = 0
|
|
|
-// } else {
|
|
|
-// self.mwcFlags.wholeWordSearch = 1
|
|
|
-// }
|
|
|
-// if self.searchField.stringValue.isEmpty == false {
|
|
|
-// self.search(self.searchField)
|
|
|
-// }
|
|
|
-// KMDataManager.ud_set(self.mwcFlags.wholeWordSearch, forKey: SKWholeWordSearchKey)
|
|
|
- }
|
|
|
-
|
|
|
- @objc func toggleCaseInsensitiveSearch(_ sender: AnyObject?) {
|
|
|
-// if self.mwcFlags.caseInsensitiveSearch == 0 {
|
|
|
-// self.mwcFlags.caseInsensitiveSearch = 1
|
|
|
-// } else {
|
|
|
-// self.mwcFlags.caseInsensitiveSearch = 0
|
|
|
-// }
|
|
|
-//
|
|
|
-// if self.searchField.stringValue.isEmpty == false {
|
|
|
-// self.search(self.searchField)
|
|
|
-// }
|
|
|
-// KMDataManager.ud_set(self.mwcFlags.caseInsensitiveSearch, forKey: SKCaseInsensitiveSearchKey)
|
|
|
- }
|
|
|
-
|
|
|
@objc func goToSelectedFindResults(_ sender: AnyObject?) {
|
|
|
// guard let olView = sender as? NSTableView, olView.clickedRow != -1 else {
|
|
|
// NSSound.beep()
|
|
@@ -417,18 +321,6 @@ class KMBotaSearchViewController: KMNBotaBaseViewController {
|
|
|
// self.updateFindResultHighlightsForDirection(.directSelection)
|
|
|
}
|
|
|
|
|
|
- @objc func searchAction(_ sender: NSSearchField) {
|
|
|
-// if sender.stringValue.isEmpty {
|
|
|
-// self.applySearchTableHeader("")
|
|
|
-// }
|
|
|
-// self.delegate?.searchAction?(searchString: sender.stringValue, isCase: self.mwcFlags.caseInsensitiveSearch == 1)
|
|
|
-
|
|
|
- handdler.search(keyword: sender.stringValue, isCase: false, isWholeWord: false) { [weak self] results in
|
|
|
- self?.searchResults = results ?? []
|
|
|
- self?.tableView.reloadData()
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
@objc func addAnnotationsForSelections(_ sender: NSMenuItem) {
|
|
|
for selection in menuSections_ {
|
|
|
// self.listView?.addAnnotation(with: CAnnotationType(rawValue: sender.tag) ?? .circle, selection: selection, page: selection.page, bounds: selection.bounds)
|
|
@@ -445,6 +337,55 @@ class KMBotaSearchViewController: KMNBotaBaseViewController {
|
|
|
// self.searchResultsView.isHidden = true
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ func updateFindResultHighlightsForDirection(_ direction: NSWindow.SelectionDirection) {
|
|
|
+ var findResults: [KMSearchMode] = handdler.searchResults
|
|
|
+ if (findResults.count == 0) {
|
|
|
+ handdler.showSelection(nil)
|
|
|
+ } else {
|
|
|
+ if direction == .directSelection {
|
|
|
+ self.searchResultIndex_ = 0
|
|
|
+ } else if (direction == .selectingNext) {
|
|
|
+ self.searchResultIndex_ += 1
|
|
|
+ if self.searchResultIndex_ >= findResults.count {
|
|
|
+ self.searchResultIndex_ = 0
|
|
|
+ }
|
|
|
+ } else if (direction == .selectingPrevious) {
|
|
|
+ self.searchResultIndex_ -= 1
|
|
|
+ if self.searchResultIndex_ < 0 {
|
|
|
+ self.searchResultIndex_ = findResults.count-1
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ let currentSel = findResults[self.searchResultIndex_].selection
|
|
|
+ if currentSel.hasCharacters() {
|
|
|
+ let page = currentSel.safeFirstPage()
|
|
|
+ var rect = NSZeroRect
|
|
|
+
|
|
|
+ for model in findResults {
|
|
|
+ if let data = page, model.selection.pages().contains(data) {
|
|
|
+ rect = NSUnionRect(rect, model.selection.bounds(for: data))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let FIND_RESULT_MARGIN = 50.0
|
|
|
+ rect = NSIntersectionRect(NSInsetRect(rect, -FIND_RESULT_MARGIN, -FIND_RESULT_MARGIN), page?.bounds(for: .cropBox) ?? .zero)
|
|
|
+ handdler.pdfView?.go(to: page)
|
|
|
+ handdler.pdfView?.go(to: rect, on: page)
|
|
|
+ }
|
|
|
+
|
|
|
+ if currentSel.hasCharacters() {
|
|
|
+ let bColor = NSColor(red: 236/255.0, green: 241/255.0, blue: 83/255.0, alpha: 0.5)
|
|
|
+ let color = NSColor(red: 219/255.0, green: 220/255.0, blue: 3/255.0, alpha: 0.5)
|
|
|
+ handdler.pdfView?.setHighlight(currentSel, forBorderColor: .clear, fill: color, animated: true)
|
|
|
+ handdler.pdfView?.go(to: currentSel, animated: true)
|
|
|
+ handdler.pdfView?.setCurrentSelection(currentSel, animate: true)
|
|
|
+ }
|
|
|
+// let mode = self.listView?.toolMode ?? .none
|
|
|
+// if mode == .moveToolMode || mode == .magnifyToolMode || mode == .selectToolMode {
|
|
|
+// self.listView?.setCurrentSelection(nil, animate: false)
|
|
|
+// }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// MARK: - NSTableViewDelegate, NSTableViewDataSource
|
|
@@ -531,29 +472,21 @@ extension KMBotaSearchViewController: NSTableViewDelegate, NSTableViewDataSource
|
|
|
}
|
|
|
|
|
|
func tableViewSelectionDidChange(_ notification: Notification) {
|
|
|
-// if self.stopRepeatLoad == true {
|
|
|
-//
|
|
|
-// } else {
|
|
|
-// self.delegate?.controller?(controller: self, listViewSelectionDidChange: notification.object, info: nil)
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
- // [self updateFindResultHighlightsForDirection:NSDirectSelection];
|
|
|
let row = self.tableView.selectedRow
|
|
|
- if row >= 0 {
|
|
|
-// let model = handdler.searchResults[row]
|
|
|
-// let isEditing = self.listView?.isEditing() ?? false
|
|
|
-// if isEditing {
|
|
|
-// self.mainViewController?.srHanddler.showSelection(model.selection)
|
|
|
-// return
|
|
|
-// }
|
|
|
+ if row < 0 || row >= datas.count {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ guard let model = datas[row] as? KMSearchMode else {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let isEditing = handdler.pdfView?.isEditing() ?? false
|
|
|
+ if isEditing {
|
|
|
+ handdler.showSelection(model.selection)
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
-// self.listView?.go(to: model.selection, animated: true)
|
|
|
- // self.listView?.setHighlightedSelection(model.selection, animated: true)
|
|
|
- DispatchQueue.main.asyncAfter(deadline: .now()+0.3) {
|
|
|
-// self.listView?.setHighlightedSelections([model.selection])
|
|
|
-// self.listView?.setNeedsDisplayAnnotationViewForVisiblePages()
|
|
|
- }
|
|
|
+ DispatchQueue.main.asyncAfter(deadline: .now()+0.3) {
|
|
|
+ self.handdler.showSelection(model.selection)
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -562,14 +495,22 @@ extension KMBotaSearchViewController: NSTableViewDelegate, NSTableViewDataSource
|
|
|
KMPurchaseCompareWindowController.sharedInstance().showWindow(nil)
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
var string = ""
|
|
|
for idx in rowIndexes {
|
|
|
-// let match = handdler.searchResults[idx].selection
|
|
|
-// string.append("* ")
|
|
|
- // [string appendFormat:NSLocalizedString(@"Page %@", @""), [match firstPageLabel]];
|
|
|
-// string = string.appendingFormat(KMLocalizedString("Page %@"), "\(match.safeFirstPage()?.pageIndex() ?? 0)")
|
|
|
- // [string appendFormat:@"", [[match contextString] string]];
|
|
|
-// string = string.appendingFormat(": %@\n", match.string() ?? "")
|
|
|
+ if idx < 0 || idx >= datas.count {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ guard let model = datas[idx] as? KMSearchMode else {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ let match = model.selection
|
|
|
+ string.append("* ")
|
|
|
+// [string appendFormat:NSLocalizedString(@"Page %@", @""), [match firstPageLabel]];
|
|
|
+ string = string.appendingFormat(KMLocalizedString("Page %@"), "\(match.safeFirstPage()?.pageIndex() ?? 0)")
|
|
|
+// [string appendFormat:@"", [[match contextString] string]];
|
|
|
+ string = string.appendingFormat(": %@\n", match.string() ?? "")
|
|
|
}
|
|
|
let pboard = NSPasteboard.general
|
|
|
pboard.clearContents()
|
|
@@ -586,7 +527,7 @@ extension KMBotaSearchViewController: KMBotaTableViewDelegate {
|
|
|
}
|
|
|
|
|
|
func tableViewMoveRight(_ aTableView: NSTableView) {
|
|
|
-// self.updateFindResultHighlightsForDirection(.selectingNext)
|
|
|
+ updateFindResultHighlightsForDirection(.selectingNext)
|
|
|
}
|
|
|
|
|
|
func tableViewMoveUp(_ aTableView: NSTableView) {
|
|
@@ -600,16 +541,18 @@ extension KMBotaSearchViewController: KMBotaTableViewDelegate {
|
|
|
}
|
|
|
|
|
|
func tableView(_ aTableView: NSTableView, imageContextForRow rowIndex: Int) -> AnyObject? {
|
|
|
- if rowIndex >= self.searchResults.count {
|
|
|
+ if rowIndex < 0 || rowIndex >= datas.count {
|
|
|
return nil
|
|
|
}
|
|
|
-// let model = self.searchResults[rowIndex]
|
|
|
-// let selection = model.selection
|
|
|
-// let x = selection.bounds.origin.x + NSWidth(selection.bounds) * 0.5
|
|
|
-// let y = selection.bounds.origin.y + NSHeight(selection.bounds) * 0.5
|
|
|
-// let point = NSPoint(x: x, y: y)
|
|
|
-// return CPDFDestination(document: self.pdfDocument(), pageIndex: Int(model.selectionPageIndex), at: point, zoom: self.scaleFactor().cgFloat)
|
|
|
- return nil
|
|
|
+ guard let model = datas[rowIndex] as? KMSearchMode else {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+
|
|
|
+ let selection = model.selection
|
|
|
+ let x = selection.bounds.origin.x + NSWidth(selection.bounds) * 0.5
|
|
|
+ let y = selection.bounds.origin.y + NSHeight(selection.bounds) * 0.5
|
|
|
+ let point = NSPoint(x: x, y: y)
|
|
|
+ return CPDFDestination(document: handdler.pdfDocument(), pageIndex: Int(model.selectionPageIndex), at: point, zoom: handdler.scaleFactor() ?? 0)
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -618,14 +561,10 @@ extension KMBotaSearchViewController: KMBotaTableViewDelegate {
|
|
|
|
|
|
extension KMBotaSearchViewController: ComponentGroupDelegate {
|
|
|
func componentGroupDidDismiss(group: ComponentGroup?) {
|
|
|
-// if group == groupView_ {
|
|
|
-// removeGroupView()
|
|
|
-// } else if group == menuGroupView_ {
|
|
|
-// group?.removeFromSuperview()
|
|
|
-// menuGroupView_ = nil
|
|
|
-// } else
|
|
|
- if group == searchGroupView {
|
|
|
-// searchGroupView_ = nil
|
|
|
+ if group == menuGroupView_ {
|
|
|
+ group?.removeFromSuperview()
|
|
|
+ menuGroupView_ = nil
|
|
|
+ } else if group == searchGroupView {
|
|
|
searchGroupTarget?.properties.state = .normal
|
|
|
searchGroupTarget?.reloadData()
|
|
|
searchGroupTarget = nil
|
|
@@ -633,18 +572,6 @@ extension KMBotaSearchViewController: ComponentGroupDelegate {
|
|
|
}
|
|
|
|
|
|
func componentGroupDidSelect(group: ComponentGroup?, menuItemProperty: ComponentMenuitemProperty?) {
|
|
|
-// if group == groupView_ {
|
|
|
-// if let selItem = menuItemProperty {
|
|
|
-// let index = group?.menuItemArr.firstIndex(of: selItem)
|
|
|
-// if index == 0 {
|
|
|
-// expandAllComments(item: NSMenuItem())
|
|
|
-// } else if index == 1 {
|
|
|
-// collapseAllComments(item: NSMenuItem())
|
|
|
-// } else if index == 2 {
|
|
|
-// removeAllOutlineItem(item: NSMenuItem())
|
|
|
-// }
|
|
|
-// }
|
|
|
-// } else
|
|
|
if group == menuGroupView_ {
|
|
|
if let selItem = menuItemProperty {
|
|
|
let index = group?.menuItemArr.firstIndex(of: selItem)
|
|
@@ -680,13 +607,27 @@ extension KMBotaSearchViewController: ComponentGroupDelegate {
|
|
|
let value = KMDataManager.ud_bool(forKey: key)
|
|
|
KMDataManager.ud_set(!value, forKey: key)
|
|
|
|
|
|
-// BOTAOutlineView.wholeWords = !value
|
|
|
+ if let data = topContentView_?.inputValue, data.isEmpty {
|
|
|
+ search(keyword: data) { [weak self] results in
|
|
|
+ self?.searchResults = results ?? []
|
|
|
+
|
|
|
+ self?.showResult()
|
|
|
+ self?.tableView.reloadData()
|
|
|
+ }
|
|
|
+ }
|
|
|
} else if idx == 4 {
|
|
|
let key = KMNSearchKey.caseSensitive.botaSearch
|
|
|
let value = KMDataManager.ud_bool(forKey: key)
|
|
|
KMDataManager.ud_set(!value, forKey: key)
|
|
|
|
|
|
-// BOTAOutlineView.caseSensitive = !value
|
|
|
+ if let data = topContentView_?.inputValue, data.isEmpty {
|
|
|
+ search(keyword: data) { [weak self] results in
|
|
|
+ self?.searchResults = results ?? []
|
|
|
+
|
|
|
+ self?.showResult()
|
|
|
+ self?.tableView.reloadData()
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|