KMLeftSideViewController+Search.swift 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //
  2. // KMLeftSideViewController+Search.swift
  3. // PDF Master
  4. //
  5. // Created by tangchao on 2023/12/24.
  6. //
  7. import Foundation
  8. // MARK: - Menu
  9. extension KMLeftSideViewController {
  10. @objc func addAnnotationsForSelections(_ sender: NSMenuItem) {
  11. guard let selections = sender.representedObject as? [CPDFSelection], selections.count > 0 else {
  12. return
  13. }
  14. for selection in selections {
  15. self.listView.addAnnotation(with: CAnnotationType(rawValue: sender.tag) ?? .circle, selection: selection, page: selection.page, bounds: selection.bounds)
  16. }
  17. }
  18. @objc func selectSelections(_ sender: NSMenuItem) {
  19. guard let selections = sender.representedObject as? [CPDFSelection], selections.count > 0 else {
  20. return
  21. }
  22. self.listView.currentSelection = CPDFSelection.selectionByAddingSelections(selections as NSArray)
  23. }
  24. @objc func toggleWholeWordSearch(_ sender: AnyObject?) {
  25. if self.mwcFlags.wholeWordSearch == 1 {
  26. self.mwcFlags.wholeWordSearch = 0
  27. } else {
  28. self.mwcFlags.wholeWordSearch = 1
  29. }
  30. if self.searchField.stringValue.isEmpty == false {
  31. self.search(self.searchField)
  32. }
  33. UserDefaults.standard.setValue(self.mwcFlags.wholeWordSearch, forKey: SKWholeWordSearchKey)
  34. UserDefaults.standard.synchronize()
  35. }
  36. }