Browse Source

【综合】搜索替换优化

tangchao 7 months ago
parent
commit
b1a57ddf31

+ 2 - 1
PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/KMLeftSideViewController.swift

@@ -1265,7 +1265,8 @@ extension KMLeftSideViewController: NSTableViewDelegate, NSTableViewDataSource {
             if row >= 0 {
                 let model = self.searchResults[row]
                 self.listView?.go(to: model.selection, animated: true)
-                self.listView?.setHighlightedSelection(model.selection, animated: true)
+//                self.listView?.setHighlightedSelection(model.selection, animated: true)
+                self.listView?.setHighlightedSelections([model.selection])
                 self.listView?.setNeedsDisplayAnnotationViewForVisiblePages()
             }
         } else if self.groupedFindTableView.isEqual(to: notification.object) {

+ 20 - 0
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/Freehand/Controller/KMFreehandAnnotationController.swift

@@ -92,6 +92,26 @@ import Cocoa
         }
     }
     
+    override func updateViewColor() {
+        super.updateViewColor()
+        
+        if KMAppearance.isDarkMode() {
+            let darkColor = NSColor(red: 57/255.0, green: 60/255.0, blue: 62/255.0, alpha: 1.0).cgColor
+            let borderColor = NSColor(red: 86/255.0, green: 88/255.0, blue: 90/255.0, alpha: 1.0).cgColor
+            
+            if let data = self.lineAndBorderItemView?.dashComboBox {
+                setViewColor(data, darkColor, borderColor)
+            }
+        } else {
+            let lightColor = NSColor.white.cgColor
+            let borderColor = NSColor(red: 218/255.0, green: 219/255.0, blue: 222/255.0, alpha: 1.0).cgColor
+            
+            if let data = self.lineAndBorderItemView?.dashComboBox {
+                setViewColor(data, lightColor, borderColor)
+            }
+        }
+    }
+    
     // MARK: - Actions
     
     @objc func lineRadioAction(_ sender: NSButton) {

+ 8 - 0
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift

@@ -4702,6 +4702,14 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
                 }
                 
                 self.view.window?.makeFirstResponder(nil)
+                let toolMode = self.listView?.toolMode ?? .none
+                let isEditing = self.listView?.isEditing() ?? false
+                if toolMode == .editPDFToolMode && isEditing {
+                    
+                } else { // 进入内容编辑模式
+                    self.toolbarController.clickItem(KMDocumentEditToolbarItemIdentifier)
+                }
+                
                 let winC = KMSearchReplaceWindowController(with: self.listView, type: .replace)
                 winC.replaceCallback = { [weak self] in
                     let toolMode = self?.listView?.toolMode ?? .none

+ 6 - 1
PDF Office/PDF Master/Class/Tools/Search/Tools/KMSearchReplaceHanddler.swift

@@ -145,7 +145,12 @@ class KMSearchReplaceHanddler: NSObject {
         let pageIdx = document.index(for: theSel.page)
         self.pdfView?.go(toPageIndex: Int(pageIdx), animated: false)
         self.pdfView?.go(to: theSel.bounds, on: theSel.page)
-        self.pdfView?.setHighlightedSelection(theSel, animated: true)
+        let isEditing = self.pdfView?.isEditing() ?? false
+        if isEditing {
+            self.pdfView?.setHighlightedSelection(theSel, animated: true)
+        } else {
+            self.pdfView?.setHighlightedSelections([theSel])
+        }
         self.pdfView?.setNeedsDisplayAnnotationViewForVisiblePages()
     }
 }

+ 4 - 0
PDF Office/PDF Master/Class/Tools/Search/Window/KMSearchReplaceWindowController.swift

@@ -120,9 +120,11 @@ class KMSearchReplaceWindowController: NSWindowController {
         self.matchWholeCheck.title = NSLocalizedString("Whole Words Only", comment: "")
         self.matchWholeCheck.target = self
         self.matchWholeCheck.action = #selector(_checkAction)
+        self.matchWholeCheck.state = .off
         self.caseSensitiveCheck.title = NSLocalizedString("Ignore Case", comment: "")
         self.caseSensitiveCheck.target = self
         self.caseSensitiveCheck.action = #selector(_checkAction)
+        self.caseSensitiveCheck.state = .off
         self.previousButton.title = NSLocalizedString("Next", comment: "")
         self.previousButton.target = self
         self.previousButton.action = #selector(_nextAction)
@@ -472,6 +474,8 @@ extension KMSearchReplaceWindowController: NSTextFieldDelegate {
                 self.nextButton.isEnabled = true
                 self.replaceButton.isEnabled = true
                 self.replaceAllButton.isEnabled = true
+                
+                self.currentSel = nil
             }
         }
     }