|
@@ -30,6 +30,8 @@ class KMSearchReplaceWindowController: KMNBaseWindowController {
|
|
|
|
|
|
private var _modalSession: NSApplication.ModalSession?
|
|
|
|
|
|
+ weak var mainVC:KMMainViewController?
|
|
|
+
|
|
|
var handdler: KMNSearchHanddler = KMNSearchHanddler() {
|
|
|
didSet {
|
|
|
if handdler.searchKey?.count ?? 0 > 0 && handdler.searchResults.count == 0 {
|
|
@@ -120,17 +122,9 @@ class KMSearchReplaceWindowController: KMNBaseWindowController {
|
|
|
|
|
|
self?.itemClick?(1, self?.handdler)
|
|
|
} else if idx == 3 {
|
|
|
- self?.switchType(.search, animate: true)
|
|
|
- self?.itemClick?(3, self?.handdler)
|
|
|
- if self?.handdler.searchKey?.count ?? 0 > 0 {
|
|
|
- self?.search(keyboard: self?.handdler.searchKey ?? "")
|
|
|
- }
|
|
|
+ self?.changeSearchType(type: .search)
|
|
|
} else if idx == 4 {
|
|
|
- self?.switchType(.replace, animate: true)
|
|
|
- self?.itemClick?(4, self?.handdler)
|
|
|
- if self?.handdler.searchKey?.count ?? 0 > 0 {
|
|
|
- self?.search(keyboard: self?.handdler.searchKey ?? "")
|
|
|
- }
|
|
|
+ self?.changeSearchType(type: .replace)
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -186,6 +180,23 @@ class KMSearchReplaceWindowController: KMNBaseWindowController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private func changeSearchType(type:KMNBotaSearchType) {
|
|
|
+ if type == .search {
|
|
|
+ self.switchType(.search, animate: true)
|
|
|
+ self.itemClick?(3, self.handdler)
|
|
|
+ if self.handdler.searchKey?.count ?? 0 > 0 {
|
|
|
+ self.search(keyboard: self.handdler.searchKey ?? "")
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if type == .replace {
|
|
|
+ self.switchType(.replace, animate: true)
|
|
|
+ self.itemClick?(4, self.handdler)
|
|
|
+ if self.handdler.searchKey?.count ?? 0 > 0 {
|
|
|
+ self.search(keyboard: self.handdler.searchKey ?? "")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
override func updateUILanguage() {
|
|
|
super.updateUILanguage()
|
|
|
}
|
|
@@ -203,6 +214,27 @@ class KMSearchReplaceWindowController: KMNBaseWindowController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ func nextButtonSupportEdit()->Bool {
|
|
|
+ if(nextButton.properties.isDisabled == false) {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
+ func previousButtonSupportEdit()->Bool {
|
|
|
+ if(previousButton.properties.isDisabled == false) {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
+ func searchSupportEdit()->Bool {
|
|
|
+ if(self.handdler.searchResults.isEmpty == false) {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
func updateButtonState() {
|
|
|
let value = searchItemView_.inputValue
|
|
|
if value.isEmpty || self.handdler.searchResults.isEmpty {
|
|
@@ -327,6 +359,22 @@ class KMSearchReplaceWindowController: KMNBaseWindowController {
|
|
|
self._showIndexTip()
|
|
|
self.updateButtonState()
|
|
|
}
|
|
|
+
|
|
|
+ func menuItemAction_performFindPanelAction(_ sender: NSMenuItem) {
|
|
|
+ if sender.tag == 0 {
|
|
|
+ let searchType = handdler.type
|
|
|
+ if searchType == .search {
|
|
|
+ self.changeSearchType(type: .replace)
|
|
|
+ } else if searchType == .replace {
|
|
|
+ self.changeSearchType(type: .search)
|
|
|
+ }
|
|
|
+ } else if sender.tag == 1 {
|
|
|
+ _nextAction(nil)
|
|
|
+ } else if sender.tag == 2 {
|
|
|
+ _previousAction(nil)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//MARK: Actions
|