From 7d6ac3cd5f51b385cc749585e0ef64ec66536734 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Sun, 31 Jul 2022 19:15:09 +0800 Subject: [PATCH] Repo // Clang-format. --- .../ControllerModules/KeyHandler_HandleComposition.swift | 1 + .../ControllerModules/KeyHandler_HandleInput.swift | 4 ++-- .../Modules/LangModelRelated/SubLMs/lmAssociates.swift | 2 +- Source/Modules/LangModelRelated/SubLMs/lmCoreEX.swift | 2 +- .../Modules/LangModelRelated/SubLMs/lmReplacements.swift | 2 +- Source/UI/CandidateUI/ctlCandidate.swift | 5 +++-- Source/UI/CandidateUI/ctlCandidateUniversal.swift | 4 ++-- Source/WindowControllers/ctlAboutWindow.swift | 4 ++-- Source/WindowControllers/ctlPrefWindow.swift | 9 ++++++--- UserPhraseEditor/ctlAboutWindow.swift | 2 +- vChewingTests/KeyHandlerTestsSCPCCHT.swift | 2 +- 11 files changed, 21 insertions(+), 16 deletions(-) diff --git a/Source/Modules/ControllerModules/KeyHandler_HandleComposition.swift b/Source/Modules/ControllerModules/KeyHandler_HandleComposition.swift index 9cecc0e8..ec5b75d5 100644 --- a/Source/Modules/ControllerModules/KeyHandler_HandleComposition.swift +++ b/Source/Modules/ControllerModules/KeyHandler_HandleComposition.swift @@ -40,6 +40,7 @@ extension KeyHandler { stateCallback: @escaping (InputStateProtocol) -> Void, errorCallback: @escaping () -> Void ) -> Bool? { + guard [.ofInputting, .ofEmpty, .ofEmptyIgnoringPreviousState].contains(state.type) else { return nil } // MARK: 注音按鍵輸入處理 (Handle BPMF Keys) diff --git a/Source/Modules/ControllerModules/KeyHandler_HandleInput.swift b/Source/Modules/ControllerModules/KeyHandler_HandleInput.swift index a0c5756d..073de884 100644 --- a/Source/Modules/ControllerModules/KeyHandler_HandleInput.swift +++ b/Source/Modules/ControllerModules/KeyHandler_HandleInput.swift @@ -159,8 +159,8 @@ extension KeyHandler { // MARK: 注音按鍵輸入處理 (Handle BPMF Keys) if let compositionHandled = handleComposition( - input: input, state: state, stateCallback: stateCallback, errorCallback: errorCallback) - { + input: input, state: state, stateCallback: stateCallback, errorCallback: errorCallback + ) { return compositionHandled } diff --git a/Source/Modules/LangModelRelated/SubLMs/lmAssociates.swift b/Source/Modules/LangModelRelated/SubLMs/lmAssociates.swift index 47f15b8c..47b572c7 100644 --- a/Source/Modules/LangModelRelated/SubLMs/lmAssociates.swift +++ b/Source/Modules/LangModelRelated/SubLMs/lmAssociates.swift @@ -62,7 +62,7 @@ extension vChewing { do { strData = try String(contentsOfFile: path, encoding: .utf8).replacingOccurrences(of: "\t", with: " ") strData = strData.replacingOccurrences(of: "\r", with: "\n") - strData.ranges(splitBy: "\n").filter({ !$0.isEmpty }).forEach { + strData.ranges(splitBy: "\n").filter { !$0.isEmpty }.forEach { let neta = strData[$0].split(separator: " ") if neta.count >= 2 { let theKey = String(neta[0]) diff --git a/Source/Modules/LangModelRelated/SubLMs/lmCoreEX.swift b/Source/Modules/LangModelRelated/SubLMs/lmCoreEX.swift index 19ed60ad..a89337c5 100644 --- a/Source/Modules/LangModelRelated/SubLMs/lmCoreEX.swift +++ b/Source/Modules/LangModelRelated/SubLMs/lmCoreEX.swift @@ -87,7 +87,7 @@ extension vChewing { do { strData = try String(contentsOfFile: path, encoding: .utf8).replacingOccurrences(of: "\t", with: " ") strData = strData.replacingOccurrences(of: "\r", with: "\n") - strData.ranges(splitBy: "\n").filter({ !$0.isEmpty }).forEach { + strData.ranges(splitBy: "\n").filter { !$0.isEmpty }.forEach { let neta = strData[$0].split(separator: " ") if neta.count >= 2, String(neta[0]).first != "#" { if !neta[0].isEmpty, !neta[1].isEmpty { diff --git a/Source/Modules/LangModelRelated/SubLMs/lmReplacements.swift b/Source/Modules/LangModelRelated/SubLMs/lmReplacements.swift index d7df5a93..16d0c0de 100644 --- a/Source/Modules/LangModelRelated/SubLMs/lmReplacements.swift +++ b/Source/Modules/LangModelRelated/SubLMs/lmReplacements.swift @@ -53,7 +53,7 @@ extension vChewing { do { strData = try String(contentsOfFile: path, encoding: .utf8).replacingOccurrences(of: "\t", with: " ") strData = strData.replacingOccurrences(of: "\r", with: "\n") - strData.ranges(splitBy: "\n").filter({ !$0.isEmpty }).forEach { + strData.ranges(splitBy: "\n").filter { !$0.isEmpty }.forEach { let neta = strData[$0].split(separator: " ") if neta.count >= 2 { let theKey = String(neta[0]) diff --git a/Source/UI/CandidateUI/ctlCandidate.swift b/Source/UI/CandidateUI/ctlCandidate.swift index 53c0c776..745f9104 100644 --- a/Source/UI/CandidateUI/ctlCandidate.swift +++ b/Source/UI/CandidateUI/ctlCandidate.swift @@ -107,12 +107,13 @@ public class ctlCandidate: NSWindowController, ctlCandidateProtocol { } } - required public init(_ layout: CandidateLayout = .horizontal) { + public required init(_: CandidateLayout = .horizontal) { super.init(window: .init()) visible = false } - required init?(coder: NSCoder) { + @available(*, unavailable) + required init?(coder _: NSCoder) { fatalError("init(coder:) has not been implemented") } diff --git a/Source/UI/CandidateUI/ctlCandidateUniversal.swift b/Source/UI/CandidateUI/ctlCandidateUniversal.swift index b96c5f10..9fc78c13 100644 --- a/Source/UI/CandidateUI/ctlCandidateUniversal.swift +++ b/Source/UI/CandidateUI/ctlCandidateUniversal.swift @@ -380,7 +380,7 @@ public class ctlCandidateUniversal: ctlCandidate { } } - required public init(_ layout: CandidateLayout = .horizontal) { + public required init(_ layout: CandidateLayout = .horizontal) { var contentRect = NSRect(x: 128.0, y: 128.0, width: 0.0, height: 0.0) let styleMask: NSWindow.StyleMask = [.nonactivatingPanel] let panel = NSPanel( @@ -449,7 +449,7 @@ public class ctlCandidateUniversal: ctlCandidate { // MARK: Post-Init() super.init(layout) - self.window = panel + window = panel currentLayout = layout candidateView.target = self diff --git a/Source/WindowControllers/ctlAboutWindow.swift b/Source/WindowControllers/ctlAboutWindow.swift index 47b767b0..b359ab0d 100644 --- a/Source/WindowControllers/ctlAboutWindow.swift +++ b/Source/WindowControllers/ctlAboutWindow.swift @@ -57,13 +57,13 @@ class ctlAboutWindow: NSWindowController { ) } - @IBAction func btnBugReport(_ sender: NSButton) { + @IBAction func btnBugReport(_: NSButton) { if let url = URL(string: "https://vchewing.github.io/BUGREPORT.html") { NSWorkspace.shared.open(url) } } - @IBAction func btnWebsite(_ sender: NSButton) { + @IBAction func btnWebsite(_: NSButton) { if let url = URL(string: "https://vchewing.github.io/") { NSWorkspace.shared.open(url) } diff --git a/Source/WindowControllers/ctlPrefWindow.swift b/Source/WindowControllers/ctlPrefWindow.swift index 41791725..3358f148 100644 --- a/Source/WindowControllers/ctlPrefWindow.swift +++ b/Source/WindowControllers/ctlPrefWindow.swift @@ -388,7 +388,8 @@ extension ctlPrefWindow: NSToolbarDelegate { item.label = title if #available(macOS 11.0, *) { item.image = NSImage( - systemSymbolName: "wrench.and.screwdriver.fill", accessibilityDescription: "General Preferences") + systemSymbolName: "wrench.and.screwdriver.fill", accessibilityDescription: "General Preferences" + ) } else { item.image = NSImage(named: NSImage.homeTemplateName) } @@ -399,7 +400,8 @@ extension ctlPrefWindow: NSToolbarDelegate { item.label = title if #available(macOS 11.0, *) { item.image = NSImage( - systemSymbolName: "person.fill.questionmark", accessibilityDescription: "Experiences Preferences") + systemSymbolName: "person.fill.questionmark", accessibilityDescription: "Experiences Preferences" + ) } else { item.image = NSImage(named: NSImage.flowViewTemplateName) } @@ -410,7 +412,8 @@ extension ctlPrefWindow: NSToolbarDelegate { item.label = title if #available(macOS 11.0, *) { item.image = NSImage( - systemSymbolName: "character.book.closed.fill", accessibilityDescription: "Dictionary Preferences") + systemSymbolName: "character.book.closed.fill", accessibilityDescription: "Dictionary Preferences" + ) } else { item.image = NSImage(named: NSImage.bookmarksTemplateName) } diff --git a/UserPhraseEditor/ctlAboutWindow.swift b/UserPhraseEditor/ctlAboutWindow.swift index e8c00e5c..fd437f46 100644 --- a/UserPhraseEditor/ctlAboutWindow.swift +++ b/UserPhraseEditor/ctlAboutWindow.swift @@ -57,7 +57,7 @@ import Cocoa ) } - @IBAction func btnWebsite(_ sender: NSButton) { + @IBAction func btnWebsite(_: NSButton) { if let url = URL(string: "https://vchewing.github.io/") { NSWorkspace.shared.open(url) } diff --git a/vChewingTests/KeyHandlerTestsSCPCCHT.swift b/vChewingTests/KeyHandlerTestsSCPCCHT.swift index edcdbcbc..43ea156b 100644 --- a/vChewingTests/KeyHandlerTestsSCPCCHT.swift +++ b/vChewingTests/KeyHandlerTestsSCPCCHT.swift @@ -357,7 +357,7 @@ extension String { extension vChewing.LMAssociates { public mutating func forceOpenStringInstead(_ strData: String) { - strData.ranges(splitBy: "\n").filter({ !$0.isEmpty }).forEach { + strData.ranges(splitBy: "\n").filter { !$0.isEmpty }.forEach { let neta = strData[$0].split(separator: " ") if neta.count >= 2 { let theKey = String(neta[0])