Repo // Remove useless do{} wrappers.

This commit is contained in:
ShikiSuen 2022-07-12 23:25:26 +08:00
parent 09cf014dca
commit 66f37fbb43
4 changed files with 170 additions and 202 deletions

View File

@ -154,20 +154,16 @@ extension KeyHandler {
if input.isLeft { if input.isLeft {
switch ctlCandidateCurrent.currentLayout { switch ctlCandidateCurrent.currentLayout {
case .horizontal: case .horizontal:
do {
if !ctlCandidateCurrent.highlightPreviousCandidate() { if !ctlCandidateCurrent.highlightPreviousCandidate() {
IME.prtDebugIntel("1145148D") IME.prtDebugIntel("1145148D")
errorCallback() errorCallback()
} }
}
case .vertical: case .vertical:
do {
if !ctlCandidateCurrent.showPreviousPage() { if !ctlCandidateCurrent.showPreviousPage() {
IME.prtDebugIntel("1919810D") IME.prtDebugIntel("1919810D")
errorCallback() errorCallback()
} }
} }
}
return true return true
} }
@ -187,20 +183,16 @@ extension KeyHandler {
if input.isRight { if input.isRight {
switch ctlCandidateCurrent.currentLayout { switch ctlCandidateCurrent.currentLayout {
case .horizontal: case .horizontal:
do {
if !ctlCandidateCurrent.highlightNextCandidate() { if !ctlCandidateCurrent.highlightNextCandidate() {
IME.prtDebugIntel("9B65138D") IME.prtDebugIntel("9B65138D")
errorCallback() errorCallback()
} }
}
case .vertical: case .vertical:
do {
if !ctlCandidateCurrent.showNextPage() { if !ctlCandidateCurrent.showNextPage() {
IME.prtDebugIntel("9244908D") IME.prtDebugIntel("9244908D")
errorCallback() errorCallback()
} }
} }
}
return true return true
} }
@ -220,20 +212,16 @@ extension KeyHandler {
if input.isUp { if input.isUp {
switch ctlCandidateCurrent.currentLayout { switch ctlCandidateCurrent.currentLayout {
case .horizontal: case .horizontal:
do {
if !ctlCandidateCurrent.showPreviousPage() { if !ctlCandidateCurrent.showPreviousPage() {
IME.prtDebugIntel("9B614524") IME.prtDebugIntel("9B614524")
errorCallback() errorCallback()
} }
}
case .vertical: case .vertical:
do {
if !ctlCandidateCurrent.highlightPreviousCandidate() { if !ctlCandidateCurrent.highlightPreviousCandidate() {
IME.prtDebugIntel("ASD9908D") IME.prtDebugIntel("ASD9908D")
errorCallback() errorCallback()
} }
} }
}
return true return true
} }
@ -242,20 +230,16 @@ extension KeyHandler {
if input.isDown { if input.isDown {
switch ctlCandidateCurrent.currentLayout { switch ctlCandidateCurrent.currentLayout {
case .horizontal: case .horizontal:
do {
if !ctlCandidateCurrent.showNextPage() { if !ctlCandidateCurrent.showNextPage() {
IME.prtDebugIntel("92B990DD") IME.prtDebugIntel("92B990DD")
errorCallback() errorCallback()
} }
}
case .vertical: case .vertical:
do {
if !ctlCandidateCurrent.highlightNextCandidate() { if !ctlCandidateCurrent.highlightNextCandidate() {
IME.prtDebugIntel("6B99908D") IME.prtDebugIntel("6B99908D")
errorCallback() errorCallback()
} }
} }
}
return true return true
} }

View File

@ -81,11 +81,9 @@ extension KeyHandler {
case 0: case 0:
tooltipParameterRef[1] = compositor.readings[compositorCursorIndex] tooltipParameterRef[1] = compositor.readings[compositorCursorIndex]
default: default:
do {
tooltipParameterRef[0] = compositor.readings[compositorCursorIndex - 1] tooltipParameterRef[0] = compositor.readings[compositorCursorIndex - 1]
tooltipParameterRef[1] = compositor.readings[compositorCursorIndex] tooltipParameterRef[1] = compositor.readings[compositorCursorIndex]
} }
}
/// ///
for (i, _) in tooltipParameterRef.enumerated() { for (i, _) in tooltipParameterRef.enumerated() {
if tooltipParameterRef[i].isEmpty { continue } if tooltipParameterRef[i].isEmpty { continue }

View File

@ -32,25 +32,19 @@ let kConnectionName = "vChewing_1_Connection"
switch max(CommandLine.arguments.count - 1, 0) { switch max(CommandLine.arguments.count - 1, 0) {
case 0: break case 0: break
case 1, 2: case 1, 2:
do {
switch CommandLine.arguments[1] { switch CommandLine.arguments[1] {
case "install": case "install":
do {
if CommandLine.arguments[1] == "install" { if CommandLine.arguments[1] == "install" {
let exitCode = IME.registerInputMethod() let exitCode = IME.registerInputMethod()
exit(exitCode) exit(exitCode)
} }
}
case "uninstall": case "uninstall":
do {
if CommandLine.arguments[1] == "uninstall" { if CommandLine.arguments[1] == "uninstall" {
let exitCode = IME.uninstall(isSudo: IME.isSudoMode) let exitCode = IME.uninstall(isSudo: IME.isSudoMode)
exit(exitCode) exit(exitCode)
} }
}
default: break default: break
} }
}
exit(0) exit(0)
default: exit(0) default: exit(0)
} }

View File

@ -162,7 +162,6 @@ private class vwrCandidateUniversal: NSView {
switch isVerticalLayout { switch isVerticalLayout {
case true: case true:
do {
var accuHeight: CGFloat = 0 var accuHeight: CGFloat = 0
for (index, elementHeight) in elementHeights.enumerated() { for (index, elementHeight) in elementHeights.enumerated() {
let currentHeight = elementHeight let currentHeight = elementHeight
@ -230,9 +229,7 @@ private class vwrCandidateUniversal: NSView {
) )
accuHeight += currentHeight accuHeight += currentHeight
} }
}
case false: case false:
do {
var accuWidth: CGFloat = 0 var accuWidth: CGFloat = 0
for (index, elementWidth) in elementWidths.enumerated() { for (index, elementWidth) in elementWidths.enumerated() {
let currentWidth = elementWidth let currentWidth = elementWidth
@ -304,7 +301,6 @@ private class vwrCandidateUniversal: NSView {
} }
} }
} }
}
private func findHitIndex(event: NSEvent) -> Int { private func findHitIndex(event: NSEvent) -> Int {
let location = convert(event.locationInWindow, to: nil) let location = convert(event.locationInWindow, to: nil)
@ -313,7 +309,6 @@ private class vwrCandidateUniversal: NSView {
} }
switch isVerticalLayout { switch isVerticalLayout {
case true: case true:
do {
var accuHeight: CGFloat = 0.0 var accuHeight: CGFloat = 0.0
for (index, elementHeight) in elementHeights.enumerated() { for (index, elementHeight) in elementHeights.enumerated() {
let currentHeight = elementHeight let currentHeight = elementHeight
@ -323,9 +318,7 @@ private class vwrCandidateUniversal: NSView {
} }
accuHeight += currentHeight accuHeight += currentHeight
} }
}
case false: case false:
do {
var accuWidth: CGFloat = 0.0 var accuWidth: CGFloat = 0.0
for (index, elementWidth) in elementWidths.enumerated() { for (index, elementWidth) in elementWidths.enumerated() {
let currentWidth = elementWidth let currentWidth = elementWidth
@ -336,7 +329,6 @@ private class vwrCandidateUniversal: NSView {
accuWidth += currentWidth + 1.0 accuWidth += currentWidth + 1.0
} }
} }
}
return NSNotFound return NSNotFound
} }