TDKCandidates // Reimplement certain features provided previously.
This commit is contained in:
parent
2c80f5fdf0
commit
d3cdc29505
|
@ -184,7 +184,6 @@ public class CandidatePool {
|
||||||
var indexSpecified = indexSpecified
|
var indexSpecified = indexSpecified
|
||||||
highlightedIndex = indexSpecified
|
highlightedIndex = indexSpecified
|
||||||
if !(0..<candidateDataAll.count).contains(highlightedIndex) {
|
if !(0..<candidateDataAll.count).contains(highlightedIndex) {
|
||||||
NSSound.beep()
|
|
||||||
switch highlightedIndex {
|
switch highlightedIndex {
|
||||||
case candidateDataAll.count...:
|
case candidateDataAll.count...:
|
||||||
currentRowNumber = candidateRows.count - 1
|
currentRowNumber = candidateRows.count - 1
|
||||||
|
@ -218,7 +217,6 @@ public class CandidatePool {
|
||||||
var indexSpecified = indexSpecified
|
var indexSpecified = indexSpecified
|
||||||
highlightedIndex = indexSpecified
|
highlightedIndex = indexSpecified
|
||||||
if !(0..<candidateDataAll.count).contains(highlightedIndex) {
|
if !(0..<candidateDataAll.count).contains(highlightedIndex) {
|
||||||
NSSound.beep()
|
|
||||||
switch highlightedIndex {
|
switch highlightedIndex {
|
||||||
case candidateDataAll.count...:
|
case candidateDataAll.count...:
|
||||||
currentColumnNumber = candidateColumns.count - 1
|
currentColumnNumber = candidateColumns.count - 1
|
||||||
|
|
|
@ -89,6 +89,12 @@ public class CtlCandidateTDK: CtlCandidate {
|
||||||
}
|
}
|
||||||
|
|
||||||
@discardableResult override public func showNextPage() -> Bool {
|
@discardableResult override public func showNextPage() -> Bool {
|
||||||
|
if (currentLayout == .horizontal && thePoolHorizontal.currentRowNumber == thePoolHorizontal.candidateRows.count - 1)
|
||||||
|
|| (currentLayout == .vertical
|
||||||
|
&& thePoolVertical.currentColumnNumber == thePoolVertical.candidateColumns.count - 1)
|
||||||
|
{
|
||||||
|
return highlightNextCandidate()
|
||||||
|
}
|
||||||
switch currentLayout {
|
switch currentLayout {
|
||||||
case .horizontal:
|
case .horizontal:
|
||||||
for _ in 0..<thePoolHorizontal.maximumRowsPerPage {
|
for _ in 0..<thePoolHorizontal.maximumRowsPerPage {
|
||||||
|
@ -105,7 +111,31 @@ public class CtlCandidateTDK: CtlCandidate {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@discardableResult override public func showNextLine() -> Bool {
|
||||||
|
if (currentLayout == .horizontal && thePoolHorizontal.currentRowNumber == thePoolHorizontal.candidateRows.count - 1)
|
||||||
|
|| (currentLayout == .vertical
|
||||||
|
&& thePoolVertical.currentColumnNumber == thePoolVertical.candidateColumns.count - 1)
|
||||||
|
{
|
||||||
|
return highlightNextCandidate()
|
||||||
|
}
|
||||||
|
switch currentLayout {
|
||||||
|
case .horizontal:
|
||||||
|
thePoolHorizontal.selectNewNeighborRow(direction: .down)
|
||||||
|
case .vertical:
|
||||||
|
thePoolVertical.selectNewNeighborColumn(direction: .right)
|
||||||
|
@unknown default:
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
updateDisplay()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
@discardableResult override public func showPreviousPage() -> Bool {
|
@discardableResult override public func showPreviousPage() -> Bool {
|
||||||
|
if (currentLayout == .horizontal && thePoolHorizontal.currentRowNumber == 0)
|
||||||
|
|| (currentLayout == .vertical && thePoolVertical.currentColumnNumber == 0)
|
||||||
|
{
|
||||||
|
return highlightPreviousCandidate()
|
||||||
|
}
|
||||||
switch currentLayout {
|
switch currentLayout {
|
||||||
case .horizontal:
|
case .horizontal:
|
||||||
for _ in 0..<thePoolHorizontal.maximumRowsPerPage {
|
for _ in 0..<thePoolHorizontal.maximumRowsPerPage {
|
||||||
|
@ -122,20 +152,12 @@ public class CtlCandidateTDK: CtlCandidate {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@discardableResult override public func showNextLine() -> Bool {
|
|
||||||
switch currentLayout {
|
|
||||||
case .horizontal:
|
|
||||||
thePoolHorizontal.selectNewNeighborRow(direction: .down)
|
|
||||||
case .vertical:
|
|
||||||
thePoolVertical.selectNewNeighborColumn(direction: .right)
|
|
||||||
@unknown default:
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
updateDisplay()
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
@discardableResult override public func showPreviousLine() -> Bool {
|
@discardableResult override public func showPreviousLine() -> Bool {
|
||||||
|
if (currentLayout == .horizontal && thePoolHorizontal.currentRowNumber == 0)
|
||||||
|
|| (currentLayout == .vertical && thePoolVertical.currentColumnNumber == 0)
|
||||||
|
{
|
||||||
|
return highlightPreviousCandidate()
|
||||||
|
}
|
||||||
switch currentLayout {
|
switch currentLayout {
|
||||||
case .horizontal:
|
case .horizontal:
|
||||||
thePoolHorizontal.selectNewNeighborRow(direction: .up)
|
thePoolHorizontal.selectNewNeighborRow(direction: .up)
|
||||||
|
@ -151,8 +173,18 @@ public class CtlCandidateTDK: CtlCandidate {
|
||||||
@discardableResult override public func highlightNextCandidate() -> Bool {
|
@discardableResult override public func highlightNextCandidate() -> Bool {
|
||||||
switch currentLayout {
|
switch currentLayout {
|
||||||
case .horizontal:
|
case .horizontal:
|
||||||
|
if thePoolHorizontal.highlightedIndex == thePoolHorizontal.candidateDataAll.count - 1 {
|
||||||
|
thePoolHorizontal.highlightHorizontal(at: 0)
|
||||||
|
delegate?.buzz()
|
||||||
|
break
|
||||||
|
}
|
||||||
thePoolHorizontal.highlightHorizontal(at: thePoolHorizontal.highlightedIndex + 1)
|
thePoolHorizontal.highlightHorizontal(at: thePoolHorizontal.highlightedIndex + 1)
|
||||||
case .vertical:
|
case .vertical:
|
||||||
|
if thePoolVertical.highlightedIndex == thePoolVertical.candidateDataAll.count - 1 {
|
||||||
|
thePoolVertical.highlightVertical(at: 0)
|
||||||
|
delegate?.buzz()
|
||||||
|
break
|
||||||
|
}
|
||||||
thePoolVertical.highlightVertical(at: thePoolVertical.highlightedIndex + 1)
|
thePoolVertical.highlightVertical(at: thePoolVertical.highlightedIndex + 1)
|
||||||
@unknown default:
|
@unknown default:
|
||||||
return false
|
return false
|
||||||
|
@ -164,8 +196,18 @@ public class CtlCandidateTDK: CtlCandidate {
|
||||||
@discardableResult override public func highlightPreviousCandidate() -> Bool {
|
@discardableResult override public func highlightPreviousCandidate() -> Bool {
|
||||||
switch currentLayout {
|
switch currentLayout {
|
||||||
case .horizontal:
|
case .horizontal:
|
||||||
|
if thePoolHorizontal.highlightedIndex == 0 {
|
||||||
|
thePoolHorizontal.highlightHorizontal(at: thePoolHorizontal.candidateDataAll.count - 1)
|
||||||
|
delegate?.buzz()
|
||||||
|
break
|
||||||
|
}
|
||||||
thePoolHorizontal.highlightHorizontal(at: thePoolHorizontal.highlightedIndex - 1)
|
thePoolHorizontal.highlightHorizontal(at: thePoolHorizontal.highlightedIndex - 1)
|
||||||
case .vertical:
|
case .vertical:
|
||||||
|
if thePoolVertical.highlightedIndex == 0 {
|
||||||
|
thePoolVertical.highlightVertical(at: thePoolVertical.candidateDataAll.count - 1)
|
||||||
|
delegate?.buzz()
|
||||||
|
break
|
||||||
|
}
|
||||||
thePoolVertical.highlightVertical(at: thePoolVertical.highlightedIndex - 1)
|
thePoolVertical.highlightVertical(at: thePoolVertical.highlightedIndex - 1)
|
||||||
@unknown default:
|
@unknown default:
|
||||||
return false
|
return false
|
||||||
|
@ -179,11 +221,11 @@ public class CtlCandidateTDK: CtlCandidate {
|
||||||
case .horizontal:
|
case .horizontal:
|
||||||
let currentRow = thePoolHorizontal.candidateRows[thePoolHorizontal.currentRowNumber]
|
let currentRow = thePoolHorizontal.candidateRows[thePoolHorizontal.currentRowNumber]
|
||||||
let actualID = max(0, min(id, currentRow.count - 1))
|
let actualID = max(0, min(id, currentRow.count - 1))
|
||||||
return thePoolHorizontal.candidateRows[thePoolHorizontal.currentRowNumber][actualID].index
|
return currentRow[actualID].index
|
||||||
case .vertical:
|
case .vertical:
|
||||||
let currentColumn = thePoolVertical.candidateColumns[thePoolVertical.currentColumnNumber]
|
let currentColumn = thePoolVertical.candidateColumns[thePoolVertical.currentColumnNumber]
|
||||||
let actualID = max(0, min(id, currentColumn.count - 1))
|
let actualID = max(0, min(id, currentColumn.count - 1))
|
||||||
return thePoolVertical.candidateColumns[thePoolVertical.currentColumnNumber][actualID].index
|
return currentColumn[actualID].index
|
||||||
@unknown default:
|
@unknown default:
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,6 +91,12 @@ public class CtlCandidateTDKBackports: CtlCandidate {
|
||||||
}
|
}
|
||||||
|
|
||||||
@discardableResult override public func showNextPage() -> Bool {
|
@discardableResult override public func showNextPage() -> Bool {
|
||||||
|
if (currentLayout == .horizontal && thePoolHorizontal.currentRowNumber == thePoolHorizontal.candidateRows.count - 1)
|
||||||
|
|| (currentLayout == .vertical
|
||||||
|
&& thePoolVertical.currentColumnNumber == thePoolVertical.candidateColumns.count - 1)
|
||||||
|
{
|
||||||
|
return highlightNextCandidate()
|
||||||
|
}
|
||||||
switch currentLayout {
|
switch currentLayout {
|
||||||
case .horizontal:
|
case .horizontal:
|
||||||
for _ in 0..<thePoolHorizontal.maximumRowsPerPage {
|
for _ in 0..<thePoolHorizontal.maximumRowsPerPage {
|
||||||
|
@ -107,7 +113,31 @@ public class CtlCandidateTDKBackports: CtlCandidate {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@discardableResult override public func showNextLine() -> Bool {
|
||||||
|
if (currentLayout == .horizontal && thePoolHorizontal.currentRowNumber == thePoolHorizontal.candidateRows.count - 1)
|
||||||
|
|| (currentLayout == .vertical
|
||||||
|
&& thePoolVertical.currentColumnNumber == thePoolVertical.candidateColumns.count - 1)
|
||||||
|
{
|
||||||
|
return highlightNextCandidate()
|
||||||
|
}
|
||||||
|
switch currentLayout {
|
||||||
|
case .horizontal:
|
||||||
|
thePoolHorizontal.selectNewNeighborRow(direction: .down)
|
||||||
|
case .vertical:
|
||||||
|
thePoolVertical.selectNewNeighborColumn(direction: .right)
|
||||||
|
@unknown default:
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
updateDisplay()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
@discardableResult override public func showPreviousPage() -> Bool {
|
@discardableResult override public func showPreviousPage() -> Bool {
|
||||||
|
if (currentLayout == .horizontal && thePoolHorizontal.currentRowNumber == 0)
|
||||||
|
|| (currentLayout == .vertical && thePoolVertical.currentColumnNumber == 0)
|
||||||
|
{
|
||||||
|
return highlightPreviousCandidate()
|
||||||
|
}
|
||||||
switch currentLayout {
|
switch currentLayout {
|
||||||
case .horizontal:
|
case .horizontal:
|
||||||
for _ in 0..<thePoolHorizontal.maximumRowsPerPage {
|
for _ in 0..<thePoolHorizontal.maximumRowsPerPage {
|
||||||
|
@ -124,20 +154,12 @@ public class CtlCandidateTDKBackports: CtlCandidate {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@discardableResult override public func showNextLine() -> Bool {
|
|
||||||
switch currentLayout {
|
|
||||||
case .horizontal:
|
|
||||||
thePoolHorizontal.selectNewNeighborRow(direction: .down)
|
|
||||||
case .vertical:
|
|
||||||
thePoolVertical.selectNewNeighborColumn(direction: .right)
|
|
||||||
@unknown default:
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
updateDisplay()
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
@discardableResult override public func showPreviousLine() -> Bool {
|
@discardableResult override public func showPreviousLine() -> Bool {
|
||||||
|
if (currentLayout == .horizontal && thePoolHorizontal.currentRowNumber == 0)
|
||||||
|
|| (currentLayout == .vertical && thePoolVertical.currentColumnNumber == 0)
|
||||||
|
{
|
||||||
|
return highlightPreviousCandidate()
|
||||||
|
}
|
||||||
switch currentLayout {
|
switch currentLayout {
|
||||||
case .horizontal:
|
case .horizontal:
|
||||||
thePoolHorizontal.selectNewNeighborRow(direction: .up)
|
thePoolHorizontal.selectNewNeighborRow(direction: .up)
|
||||||
|
@ -153,8 +175,18 @@ public class CtlCandidateTDKBackports: CtlCandidate {
|
||||||
@discardableResult override public func highlightNextCandidate() -> Bool {
|
@discardableResult override public func highlightNextCandidate() -> Bool {
|
||||||
switch currentLayout {
|
switch currentLayout {
|
||||||
case .horizontal:
|
case .horizontal:
|
||||||
|
if thePoolHorizontal.highlightedIndex == thePoolHorizontal.candidateDataAll.count - 1 {
|
||||||
|
thePoolHorizontal.highlightHorizontal(at: 0)
|
||||||
|
delegate?.buzz()
|
||||||
|
break
|
||||||
|
}
|
||||||
thePoolHorizontal.highlightHorizontal(at: thePoolHorizontal.highlightedIndex + 1)
|
thePoolHorizontal.highlightHorizontal(at: thePoolHorizontal.highlightedIndex + 1)
|
||||||
case .vertical:
|
case .vertical:
|
||||||
|
if thePoolVertical.highlightedIndex == thePoolVertical.candidateDataAll.count - 1 {
|
||||||
|
thePoolVertical.highlightVertical(at: 0)
|
||||||
|
delegate?.buzz()
|
||||||
|
break
|
||||||
|
}
|
||||||
thePoolVertical.highlightVertical(at: thePoolVertical.highlightedIndex + 1)
|
thePoolVertical.highlightVertical(at: thePoolVertical.highlightedIndex + 1)
|
||||||
@unknown default:
|
@unknown default:
|
||||||
return false
|
return false
|
||||||
|
@ -166,8 +198,18 @@ public class CtlCandidateTDKBackports: CtlCandidate {
|
||||||
@discardableResult override public func highlightPreviousCandidate() -> Bool {
|
@discardableResult override public func highlightPreviousCandidate() -> Bool {
|
||||||
switch currentLayout {
|
switch currentLayout {
|
||||||
case .horizontal:
|
case .horizontal:
|
||||||
|
if thePoolHorizontal.highlightedIndex == 0 {
|
||||||
|
thePoolHorizontal.highlightHorizontal(at: thePoolHorizontal.candidateDataAll.count - 1)
|
||||||
|
delegate?.buzz()
|
||||||
|
break
|
||||||
|
}
|
||||||
thePoolHorizontal.highlightHorizontal(at: thePoolHorizontal.highlightedIndex - 1)
|
thePoolHorizontal.highlightHorizontal(at: thePoolHorizontal.highlightedIndex - 1)
|
||||||
case .vertical:
|
case .vertical:
|
||||||
|
if thePoolVertical.highlightedIndex == 0 {
|
||||||
|
thePoolVertical.highlightVertical(at: thePoolVertical.candidateDataAll.count - 1)
|
||||||
|
delegate?.buzz()
|
||||||
|
break
|
||||||
|
}
|
||||||
thePoolVertical.highlightVertical(at: thePoolVertical.highlightedIndex - 1)
|
thePoolVertical.highlightVertical(at: thePoolVertical.highlightedIndex - 1)
|
||||||
@unknown default:
|
@unknown default:
|
||||||
return false
|
return false
|
||||||
|
@ -181,11 +223,11 @@ public class CtlCandidateTDKBackports: CtlCandidate {
|
||||||
case .horizontal:
|
case .horizontal:
|
||||||
let currentRow = thePoolHorizontal.candidateRows[thePoolHorizontal.currentRowNumber]
|
let currentRow = thePoolHorizontal.candidateRows[thePoolHorizontal.currentRowNumber]
|
||||||
let actualID = max(0, min(id, currentRow.count - 1))
|
let actualID = max(0, min(id, currentRow.count - 1))
|
||||||
return thePoolHorizontal.candidateRows[thePoolHorizontal.currentRowNumber][actualID].index
|
return currentRow[actualID].index
|
||||||
case .vertical:
|
case .vertical:
|
||||||
let currentColumn = thePoolVertical.candidateColumns[thePoolVertical.currentColumnNumber]
|
let currentColumn = thePoolVertical.candidateColumns[thePoolVertical.currentColumnNumber]
|
||||||
let actualID = max(0, min(id, currentColumn.count - 1))
|
let actualID = max(0, min(id, currentColumn.count - 1))
|
||||||
return thePoolVertical.candidateColumns[thePoolVertical.currentColumnNumber][actualID].index
|
return currentColumn[actualID].index
|
||||||
@unknown default:
|
@unknown default:
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue