Proj // Shorten the naming of Candidate Controllers.

This commit is contained in:
ShikiSuen 2022-04-04 13:21:27 +08:00
parent 1f6cf32159
commit c72f1c10a7
7 changed files with 103 additions and 111 deletions

View File

@ -39,10 +39,8 @@ extern InputMode imeModeNULL;
@class KeyHandler; @class KeyHandler;
@protocol KeyHandlerDelegate <NSObject> @protocol KeyHandlerDelegate <NSObject>
- (id)candidateControllerForKeyHandler:(KeyHandler *)keyHandler; - (id)ctlCandidateForKeyHandler:(KeyHandler *)keyHandler;
- (void)keyHandler:(KeyHandler *)keyHandler - (void)keyHandler:(KeyHandler *)keyHandler didSelectCandidateAtIndex:(NSInteger)index ctlCandidate:(id)controller;
didSelectCandidateAtIndex:(NSInteger)index
candidateController:(id)controller;
- (BOOL)keyHandler:(KeyHandler *)keyHandler didRequestWriteUserPhraseWithState:(InputState *)state; - (BOOL)keyHandler:(KeyHandler *)keyHandler didRequestWriteUserPhraseWithState:(InputState *)state;
@end @end

View File

@ -1261,7 +1261,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
{ {
NSString *inputText = input.inputText; NSString *inputText = input.inputText;
UniChar charCode = input.charCode; UniChar charCode = input.charCode;
VTCandidateController *gCurrentCandidateController = [self.delegate candidateControllerForKeyHandler:self]; ctlCandidate *ctlCandidateCurrent = [self.delegate ctlCandidateForKeyHandler:self];
BOOL cancelCandidateKey = [input isBackSpace] || [input isESC] || [input isDelete] || BOOL cancelCandidateKey = [input isBackSpace] || [input isESC] || [input isDelete] ||
(([input isCursorBackward] || [input isCursorForward]) && [input isShiftHold]); (([input isCursorBackward] || [input isCursorForward]) && [input isShiftHold]);
@ -1306,18 +1306,18 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
return YES; return YES;
} }
[self.delegate keyHandler:self [self.delegate keyHandler:self
didSelectCandidateAtIndex:gCurrentCandidateController.selectedCandidateIndex didSelectCandidateAtIndex:ctlCandidateCurrent.selectedCandidateIndex
candidateController:gCurrentCandidateController]; ctlCandidate:ctlCandidateCurrent];
return YES; return YES;
} }
if ([input isTab]) if ([input isTab])
{ {
BOOL updated = mgrPrefs.specifyTabKeyBehavior BOOL updated =
? ([input isShiftHold] ? [gCurrentCandidateController showPreviousPage] mgrPrefs.specifyTabKeyBehavior
: [gCurrentCandidateController showNextPage]) ? ([input isShiftHold] ? [ctlCandidateCurrent showPreviousPage] : [ctlCandidateCurrent showNextPage])
: ([input isShiftHold] ? [gCurrentCandidateController highlightPreviousCandidate] : ([input isShiftHold] ? [ctlCandidateCurrent highlightPreviousCandidate]
: [gCurrentCandidateController highlightNextCandidate]); : [ctlCandidateCurrent highlightNextCandidate]);
if (!updated) if (!updated)
{ {
[IME prtDebugIntel:@"9B691919"]; [IME prtDebugIntel:@"9B691919"];
@ -1329,10 +1329,10 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
if ([input isSpace]) if ([input isSpace])
{ {
BOOL updated = mgrPrefs.specifySpaceKeyBehavior BOOL updated = mgrPrefs.specifySpaceKeyBehavior
? ([input isShiftHold] ? [gCurrentCandidateController highlightNextCandidate] ? ([input isShiftHold] ? [ctlCandidateCurrent highlightNextCandidate]
: [gCurrentCandidateController showNextPage]) : [ctlCandidateCurrent showNextPage])
: ([input isShiftHold] ? [gCurrentCandidateController showNextPage] : ([input isShiftHold] ? [ctlCandidateCurrent showNextPage]
: [gCurrentCandidateController highlightNextCandidate]); : [ctlCandidateCurrent highlightNextCandidate]);
if (!updated) if (!updated)
{ {
[IME prtDebugIntel:@"A11C781F"]; [IME prtDebugIntel:@"A11C781F"];
@ -1343,7 +1343,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
if ([input isPageDown] || input.emacsKey == vChewingEmacsKeyNextPage) if ([input isPageDown] || input.emacsKey == vChewingEmacsKeyNextPage)
{ {
BOOL updated = [gCurrentCandidateController showNextPage]; BOOL updated = [ctlCandidateCurrent showNextPage];
if (!updated) if (!updated)
{ {
[IME prtDebugIntel:@"9B691919"]; [IME prtDebugIntel:@"9B691919"];
@ -1354,7 +1354,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
if ([input isPageUp]) if ([input isPageUp])
{ {
BOOL updated = [gCurrentCandidateController showPreviousPage]; BOOL updated = [ctlCandidateCurrent showPreviousPage];
if (!updated) if (!updated)
{ {
[IME prtDebugIntel:@"9569955D"]; [IME prtDebugIntel:@"9569955D"];
@ -1365,9 +1365,9 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
if ([input isLeft]) if ([input isLeft])
{ {
if ([gCurrentCandidateController isKindOfClass:[VTHorizontalCandidateController class]]) if ([ctlCandidateCurrent isKindOfClass:[ctlCandidateHorizontal class]])
{ {
BOOL updated = [gCurrentCandidateController highlightPreviousCandidate]; BOOL updated = [ctlCandidateCurrent highlightPreviousCandidate];
if (!updated) if (!updated)
{ {
[IME prtDebugIntel:@"1145148D"]; [IME prtDebugIntel:@"1145148D"];
@ -1376,7 +1376,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
} }
else else
{ {
BOOL updated = [gCurrentCandidateController showPreviousPage]; BOOL updated = [ctlCandidateCurrent showPreviousPage];
if (!updated) if (!updated)
{ {
[IME prtDebugIntel:@"1919810D"]; [IME prtDebugIntel:@"1919810D"];
@ -1388,7 +1388,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
if (input.emacsKey == vChewingEmacsKeyBackward) if (input.emacsKey == vChewingEmacsKeyBackward)
{ {
BOOL updated = [gCurrentCandidateController highlightPreviousCandidate]; BOOL updated = [ctlCandidateCurrent highlightPreviousCandidate];
if (!updated) if (!updated)
{ {
[IME prtDebugIntel:@"9B89308D"]; [IME prtDebugIntel:@"9B89308D"];
@ -1399,9 +1399,9 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
if ([input isRight]) if ([input isRight])
{ {
if ([gCurrentCandidateController isKindOfClass:[VTHorizontalCandidateController class]]) if ([ctlCandidateCurrent isKindOfClass:[ctlCandidateHorizontal class]])
{ {
BOOL updated = [gCurrentCandidateController highlightNextCandidate]; BOOL updated = [ctlCandidateCurrent highlightNextCandidate];
if (!updated) if (!updated)
{ {
[IME prtDebugIntel:@"9B65138D"]; [IME prtDebugIntel:@"9B65138D"];
@ -1410,7 +1410,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
} }
else else
{ {
BOOL updated = [gCurrentCandidateController showNextPage]; BOOL updated = [ctlCandidateCurrent showNextPage];
if (!updated) if (!updated)
{ {
[IME prtDebugIntel:@"9244908D"]; [IME prtDebugIntel:@"9244908D"];
@ -1422,7 +1422,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
if (input.emacsKey == vChewingEmacsKeyForward) if (input.emacsKey == vChewingEmacsKeyForward)
{ {
BOOL updated = [gCurrentCandidateController highlightNextCandidate]; BOOL updated = [ctlCandidateCurrent highlightNextCandidate];
if (!updated) if (!updated)
{ {
[IME prtDebugIntel:@"9B2428D"]; [IME prtDebugIntel:@"9B2428D"];
@ -1433,9 +1433,9 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
if ([input isUp]) if ([input isUp])
{ {
if ([gCurrentCandidateController isKindOfClass:[VTHorizontalCandidateController class]]) if ([ctlCandidateCurrent isKindOfClass:[ctlCandidateHorizontal class]])
{ {
BOOL updated = [gCurrentCandidateController showPreviousPage]; BOOL updated = [ctlCandidateCurrent showPreviousPage];
if (!updated) if (!updated)
{ {
[IME prtDebugIntel:@"9B614524"]; [IME prtDebugIntel:@"9B614524"];
@ -1444,7 +1444,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
} }
else else
{ {
BOOL updated = [gCurrentCandidateController highlightPreviousCandidate]; BOOL updated = [ctlCandidateCurrent highlightPreviousCandidate];
if (!updated) if (!updated)
{ {
[IME prtDebugIntel:@"ASD9908D"]; [IME prtDebugIntel:@"ASD9908D"];
@ -1456,9 +1456,9 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
if ([input isDown]) if ([input isDown])
{ {
if ([gCurrentCandidateController isKindOfClass:[VTHorizontalCandidateController class]]) if ([ctlCandidateCurrent isKindOfClass:[ctlCandidateHorizontal class]])
{ {
BOOL updated = [gCurrentCandidateController showNextPage]; BOOL updated = [ctlCandidateCurrent showNextPage];
if (!updated) if (!updated)
{ {
[IME prtDebugIntel:@"92B990DD"]; [IME prtDebugIntel:@"92B990DD"];
@ -1467,7 +1467,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
} }
else else
{ {
BOOL updated = [gCurrentCandidateController highlightNextCandidate]; BOOL updated = [ctlCandidateCurrent highlightNextCandidate];
if (!updated) if (!updated)
{ {
[IME prtDebugIntel:@"6B99908D"]; [IME prtDebugIntel:@"6B99908D"];
@ -1479,14 +1479,14 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
if ([input isHome] || input.emacsKey == vChewingEmacsKeyHome) if ([input isHome] || input.emacsKey == vChewingEmacsKeyHome)
{ {
if (gCurrentCandidateController.selectedCandidateIndex == 0) if (ctlCandidateCurrent.selectedCandidateIndex == 0)
{ {
[IME prtDebugIntel:@"9B6EDE8D"]; [IME prtDebugIntel:@"9B6EDE8D"];
errorCallback(); errorCallback();
} }
else else
{ {
gCurrentCandidateController.selectedCandidateIndex = 0; ctlCandidateCurrent.selectedCandidateIndex = 0;
} }
return YES; return YES;
@ -1510,14 +1510,14 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
if (([input isEnd] || input.emacsKey == vChewingEmacsKeyEnd) && candidates.count > 0) if (([input isEnd] || input.emacsKey == vChewingEmacsKeyEnd) && candidates.count > 0)
{ {
if (gCurrentCandidateController.selectedCandidateIndex == candidates.count - 1) if (ctlCandidateCurrent.selectedCandidateIndex == candidates.count - 1)
{ {
[IME prtDebugIntel:@"9B69AAAD"]; [IME prtDebugIntel:@"9B69AAAD"];
errorCallback(); errorCallback();
} }
else else
{ {
gCurrentCandidateController.selectedCandidateIndex = candidates.count - 1; ctlCandidateCurrent.selectedCandidateIndex = candidates.count - 1;
} }
return YES; return YES;
} }
@ -1541,9 +1541,9 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
match = inputText; match = inputText;
} }
for (NSUInteger j = 0, c = [gCurrentCandidateController.keyLabels count]; j < c; j++) for (NSUInteger j = 0, c = [ctlCandidateCurrent.keyLabels count]; j < c; j++)
{ {
VTCandidateKeyLabel *label = gCurrentCandidateController.keyLabels[j]; VTCandidateKeyLabel *label = ctlCandidateCurrent.keyLabels[j];
if ([match compare:label.key options:NSCaseInsensitiveSearch] == NSOrderedSame) if ([match compare:label.key options:NSCaseInsensitiveSearch] == NSOrderedSame)
{ {
index = j; index = j;
@ -1553,12 +1553,10 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
if (index != NSNotFound) if (index != NSNotFound)
{ {
NSUInteger candidateIndex = [gCurrentCandidateController candidateIndexAtKeyLabelIndex:index]; NSUInteger candidateIndex = [ctlCandidateCurrent candidateIndexAtKeyLabelIndex:index];
if (candidateIndex != NSUIntegerMax) if (candidateIndex != NSUIntegerMax)
{ {
[self.delegate keyHandler:self [self.delegate keyHandler:self didSelectCandidateAtIndex:candidateIndex ctlCandidate:ctlCandidateCurrent];
didSelectCandidateAtIndex:candidateIndex
candidateController:gCurrentCandidateController];
return YES; return YES;
} }
} }
@ -1606,12 +1604,12 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
if (shouldAutoSelectCandidate) if (shouldAutoSelectCandidate)
{ {
NSUInteger candidateIndex = [gCurrentCandidateController candidateIndexAtKeyLabelIndex:0]; NSUInteger candidateIndex = [ctlCandidateCurrent candidateIndexAtKeyLabelIndex:0];
if (candidateIndex != NSUIntegerMax) if (candidateIndex != NSUIntegerMax)
{ {
[self.delegate keyHandler:self [self.delegate keyHandler:self
didSelectCandidateAtIndex:candidateIndex didSelectCandidateAtIndex:candidateIndex
candidateController:gCurrentCandidateController]; ctlCandidate:ctlCandidateCurrent];
[self clear]; [self clear];
InputStateEmptyIgnoringPreviousState *empty = [[InputStateEmptyIgnoringPreviousState alloc] init]; InputStateEmptyIgnoringPreviousState *empty = [[InputStateEmptyIgnoringPreviousState alloc] init];
stateCallback(empty); stateCallback(empty);

View File

@ -35,11 +35,11 @@ extension Bool {
private let kMinKeyLabelSize: CGFloat = 10 private let kMinKeyLabelSize: CGFloat = 10
private var gCurrentCandidateController: CandidateController? private var ctlCandidateCurrent: ctlCandidate?
extension CandidateController { extension ctlCandidate {
fileprivate static let horizontal = HorizontalCandidateController() fileprivate static let horizontal = ctlCandidateHorizontal()
fileprivate static let vertical = VerticalCandidateController() fileprivate static let vertical = ctlCandidateVertical()
} }
@objc(ctlInputMethod) @objc(ctlInputMethod)
@ -500,8 +500,8 @@ extension ctlInputMethod {
private func handle(state: InputState.Deactivated, previous: InputState, client: Any?) { private func handle(state: InputState.Deactivated, previous: InputState, client: Any?) {
currentCandidateClient = nil currentCandidateClient = nil
gCurrentCandidateController?.delegate = nil ctlCandidateCurrent?.delegate = nil
gCurrentCandidateController?.visible = false ctlCandidateCurrent?.visible = false
hideTooltip() hideTooltip()
if let previous = previous as? InputState.NotEmpty { if let previous = previous as? InputState.NotEmpty {
@ -513,7 +513,7 @@ extension ctlInputMethod {
} }
private func handle(state: InputState.Empty, previous: InputState, client: Any?) { private func handle(state: InputState.Empty, previous: InputState, client: Any?) {
gCurrentCandidateController?.visible = false ctlCandidateCurrent?.visible = false
hideTooltip() hideTooltip()
guard let client = client as? IMKTextInput else { guard let client = client as? IMKTextInput else {
@ -531,7 +531,7 @@ extension ctlInputMethod {
private func handle( private func handle(
state: InputState.EmptyIgnoringPreviousState, previous: InputState, client: Any! state: InputState.EmptyIgnoringPreviousState, previous: InputState, client: Any!
) { ) {
gCurrentCandidateController?.visible = false ctlCandidateCurrent?.visible = false
hideTooltip() hideTooltip()
guard let client = client as? IMKTextInput else { guard let client = client as? IMKTextInput else {
@ -544,7 +544,7 @@ extension ctlInputMethod {
} }
private func handle(state: InputState.Committing, previous: InputState, client: Any?) { private func handle(state: InputState.Committing, previous: InputState, client: Any?) {
gCurrentCandidateController?.visible = false ctlCandidateCurrent?.visible = false
hideTooltip() hideTooltip()
guard let client = client as? IMKTextInput else { guard let client = client as? IMKTextInput else {
@ -561,7 +561,7 @@ extension ctlInputMethod {
} }
private func handle(state: InputState.Inputting, previous: InputState, client: Any?) { private func handle(state: InputState.Inputting, previous: InputState, client: Any?) {
gCurrentCandidateController?.visible = false ctlCandidateCurrent?.visible = false
hideTooltip() hideTooltip()
guard let client = client as? IMKTextInput else { guard let client = client as? IMKTextInput else {
@ -586,7 +586,7 @@ extension ctlInputMethod {
} }
private func handle(state: InputState.Marking, previous: InputState, client: Any?) { private func handle(state: InputState.Marking, previous: InputState, client: Any?) {
gCurrentCandidateController?.visible = false ctlCandidateCurrent?.visible = false
guard let client = client as? IMKTextInput else { guard let client = client as? IMKTextInput else {
hideTooltip() hideTooltip()
return return
@ -610,7 +610,7 @@ extension ctlInputMethod {
private func handle(state: InputState.ChoosingCandidate, previous: InputState, client: Any?) { private func handle(state: InputState.ChoosingCandidate, previous: InputState, client: Any?) {
hideTooltip() hideTooltip()
guard let client = client as? IMKTextInput else { guard let client = client as? IMKTextInput else {
gCurrentCandidateController?.visible = false ctlCandidateCurrent?.visible = false
return return
} }
@ -625,7 +625,7 @@ extension ctlInputMethod {
private func handle(state: InputState.AssociatedPhrases, previous: InputState, client: Any?) { private func handle(state: InputState.AssociatedPhrases, previous: InputState, client: Any?) {
hideTooltip() hideTooltip()
guard let client = client as? IMKTextInput else { guard let client = client as? IMKTextInput else {
gCurrentCandidateController?.visible = false ctlCandidateCurrent?.visible = false
return return
} }
client.setMarkedText( client.setMarkedText(
@ -664,14 +664,14 @@ extension ctlInputMethod {
return false return false
}() }()
gCurrentCandidateController?.delegate = nil ctlCandidateCurrent?.delegate = nil
if useVerticalMode { if useVerticalMode {
gCurrentCandidateController = .vertical ctlCandidateCurrent = .vertical
} else if mgrPrefs.useHorizontalCandidateList { } else if mgrPrefs.useHorizontalCandidateList {
gCurrentCandidateController = .horizontal ctlCandidateCurrent = .horizontal
} else { } else {
gCurrentCandidateController = .vertical ctlCandidateCurrent = .vertical
} }
// set the attributes for the candidate panel (which uses NSAttributedString) // set the attributes for the candidate panel (which uses NSAttributedString)
@ -699,24 +699,24 @@ extension ctlInputMethod {
return finalReturnFont return finalReturnFont
} }
gCurrentCandidateController?.keyLabelFont = labelFont( ctlCandidateCurrent?.keyLabelFont = labelFont(
name: mgrPrefs.candidateKeyLabelFontName, size: keyLabelSize) name: mgrPrefs.candidateKeyLabelFontName, size: keyLabelSize)
gCurrentCandidateController?.candidateFont = candidateFont( ctlCandidateCurrent?.candidateFont = candidateFont(
name: mgrPrefs.candidateTextFontName, size: textSize) name: mgrPrefs.candidateTextFontName, size: textSize)
let candidateKeys = mgrPrefs.candidateKeys let candidateKeys = mgrPrefs.candidateKeys
let keyLabels = let keyLabels =
candidateKeys.count > 4 ? Array(candidateKeys) : Array(mgrPrefs.defaultCandidateKeys) candidateKeys.count > 4 ? Array(candidateKeys) : Array(mgrPrefs.defaultCandidateKeys)
let keyLabelSuffix = state is InputState.AssociatedPhrases ? "^" : "" let keyLabelSuffix = state is InputState.AssociatedPhrases ? "^" : ""
gCurrentCandidateController?.keyLabels = keyLabels.map { ctlCandidateCurrent?.keyLabels = keyLabels.map {
CandidateKeyLabel(key: String($0), displayedText: String($0) + keyLabelSuffix) CandidateKeyLabel(key: String($0), displayedText: String($0) + keyLabelSuffix)
} }
gCurrentCandidateController?.delegate = self ctlCandidateCurrent?.delegate = self
gCurrentCandidateController?.reloadData() ctlCandidateCurrent?.reloadData()
currentCandidateClient = client currentCandidateClient = client
gCurrentCandidateController?.visible = true ctlCandidateCurrent?.visible = true
var lineHeightRect = NSMakeRect(0.0, 0.0, 16.0, 16.0) var lineHeightRect = NSMakeRect(0.0, 0.0, 16.0, 16.0)
var cursor: Int = 0 var cursor: Int = 0
@ -735,13 +735,13 @@ extension ctlInputMethod {
} }
if useVerticalMode { if useVerticalMode {
gCurrentCandidateController?.set( ctlCandidateCurrent?.set(
windowTopLeftPoint: NSMakePoint( windowTopLeftPoint: NSMakePoint(
lineHeightRect.origin.x + lineHeightRect.size.width + 4.0, lineHeightRect.origin.x + lineHeightRect.size.width + 4.0,
lineHeightRect.origin.y - 4.0), lineHeightRect.origin.y - 4.0),
bottomOutOfScreenAdjustmentHeight: lineHeightRect.size.height + 4.0) bottomOutOfScreenAdjustmentHeight: lineHeightRect.size.height + 4.0)
} else { } else {
gCurrentCandidateController?.set( ctlCandidateCurrent?.set(
windowTopLeftPoint: NSMakePoint( windowTopLeftPoint: NSMakePoint(
lineHeightRect.origin.x, lineHeightRect.origin.y - 4.0), lineHeightRect.origin.x, lineHeightRect.origin.y - 4.0),
bottomOutOfScreenAdjustmentHeight: lineHeightRect.size.height + 4.0) bottomOutOfScreenAdjustmentHeight: lineHeightRect.size.height + 4.0)
@ -776,16 +776,16 @@ extension ctlInputMethod {
// MARK: - // MARK: -
extension ctlInputMethod: KeyHandlerDelegate { extension ctlInputMethod: KeyHandlerDelegate {
func candidateController(for keyHandler: KeyHandler) -> Any { func ctlCandidate(for keyHandler: KeyHandler) -> Any {
gCurrentCandidateController ?? .vertical ctlCandidateCurrent ?? .vertical
} }
func keyHandler( func keyHandler(
_ keyHandler: KeyHandler, didSelectCandidateAt index: Int, _ keyHandler: KeyHandler, didSelectCandidateAt index: Int,
candidateController controller: Any ctlCandidate controller: Any
) { ) {
if let controller = controller as? CandidateController { if let controller = controller as? ctlCandidate {
self.candidateController(controller, didSelectCandidateAtIndex: UInt(index)) self.ctlCandidate(controller, didSelectCandidateAtIndex: UInt(index))
} }
} }
@ -815,8 +815,8 @@ extension ctlInputMethod: KeyHandlerDelegate {
// MARK: - // MARK: -
extension ctlInputMethod: CandidateControllerDelegate { extension ctlInputMethod: ctlCandidateDelegate {
func candidateCountForController(_ controller: CandidateController) -> UInt { func candidateCountForController(_ controller: ctlCandidate) -> UInt {
if let state = state as? InputState.ChoosingCandidate { if let state = state as? InputState.ChoosingCandidate {
return UInt(state.candidates.count) return UInt(state.candidates.count)
} else if let state = state as? InputState.AssociatedPhrases { } else if let state = state as? InputState.AssociatedPhrases {
@ -825,7 +825,7 @@ extension ctlInputMethod: CandidateControllerDelegate {
return 0 return 0
} }
func candidateController(_ controller: CandidateController, candidateAtIndex index: UInt) func ctlCandidate(_ controller: ctlCandidate, candidateAtIndex index: UInt)
-> String -> String
{ {
if let state = state as? InputState.ChoosingCandidate { if let state = state as? InputState.ChoosingCandidate {
@ -836,9 +836,7 @@ extension ctlInputMethod: CandidateControllerDelegate {
return "" return ""
} }
func candidateController( func ctlCandidate(_ controller: ctlCandidate, didSelectCandidateAtIndex index: UInt) {
_ controller: CandidateController, didSelectCandidateAtIndex index: UInt
) {
let client = currentCandidateClient let client = currentCandidateClient
if let state = state as? InputState.SymbolTable, if let state = state as? InputState.SymbolTable,

View File

@ -38,18 +38,18 @@ public class CandidateKeyLabel: NSObject {
} }
} }
@objc(VTCandidateControllerDelegate) @objc(ctlCandidateDelegate)
public protocol CandidateControllerDelegate: AnyObject { public protocol ctlCandidateDelegate: AnyObject {
func candidateCountForController(_ controller: CandidateController) -> UInt func candidateCountForController(_ controller: ctlCandidate) -> UInt
func candidateController(_ controller: CandidateController, candidateAtIndex index: UInt) func ctlCandidate(_ controller: ctlCandidate, candidateAtIndex index: UInt)
-> String -> String
func candidateController( func ctlCandidate(
_ controller: CandidateController, didSelectCandidateAtIndex index: UInt) _ controller: ctlCandidate, didSelectCandidateAtIndex index: UInt)
} }
@objc(VTCandidateController) @objc(ctlCandidate)
public class CandidateController: NSWindowController { public class ctlCandidate: NSWindowController {
@objc public weak var delegate: CandidateControllerDelegate? { @objc public weak var delegate: ctlCandidateDelegate? {
didSet { didSet {
reloadData() reloadData()
} }

View File

@ -236,8 +236,7 @@ private class HorizontalCandidateView: NSView {
} }
} }
@objc(VTHorizontalCandidateController) @objc public class ctlCandidateHorizontal: ctlCandidate {
public class HorizontalCandidateController: CandidateController {
private var candidateView: HorizontalCandidateView private var candidateView: HorizontalCandidateView
private var prevPageButton: NSButton private var prevPageButton: NSButton
private var nextPageButton: NSButton private var nextPageButton: NSButton
@ -379,7 +378,7 @@ public class HorizontalCandidateController: CandidateController {
} }
} }
extension HorizontalCandidateController { extension ctlCandidateHorizontal {
private var pageCount: UInt { private var pageCount: UInt {
guard let delegate = delegate else { guard let delegate = delegate else {
@ -402,7 +401,7 @@ extension HorizontalCandidateController {
let begin = currentPage * keyLabelCount let begin = currentPage * keyLabelCount
for index in begin..<min(begin + keyLabelCount, count) { for index in begin..<min(begin + keyLabelCount, count) {
let candidate = delegate.candidateController(self, candidateAtIndex: index) let candidate = delegate.ctlCandidate(self, candidateAtIndex: index)
candidates.append(candidate) candidates.append(candidate)
} }
candidateView.set( candidateView.set(
@ -456,7 +455,7 @@ extension HorizontalCandidateController {
} }
@objc fileprivate func candidateViewMouseDidClick(_ sender: Any) { @objc fileprivate func candidateViewMouseDidClick(_ sender: Any) {
delegate?.candidateController(self, didSelectCandidateAtIndex: selectedCandidateIndex) delegate?.ctlCandidate(self, didSelectCandidateAtIndex: selectedCandidateIndex)
} }
} }

View File

@ -241,8 +241,7 @@ private class VerticalCandidateView: NSView {
} }
} }
@objc(VTVerticalCandidateController) @objc public class ctlCandidateVertical: ctlCandidate {
public class VerticalCandidateController: CandidateController {
private var candidateView: VerticalCandidateView private var candidateView: VerticalCandidateView
private var prevPageButton: NSButton private var prevPageButton: NSButton
private var nextPageButton: NSButton private var nextPageButton: NSButton
@ -384,7 +383,7 @@ public class VerticalCandidateController: CandidateController {
} }
} }
extension VerticalCandidateController { extension ctlCandidateVertical {
private var pageCount: UInt { private var pageCount: UInt {
guard let delegate = delegate else { guard let delegate = delegate else {
@ -407,7 +406,7 @@ extension VerticalCandidateController {
let begin = currentPage * keyLabelCount let begin = currentPage * keyLabelCount
for index in begin..<min(begin + keyLabelCount, count) { for index in begin..<min(begin + keyLabelCount, count) {
let candidate = delegate.candidateController(self, candidateAtIndex: index) let candidate = delegate.ctlCandidate(self, candidateAtIndex: index)
candidates.append(candidate) candidates.append(candidate)
} }
candidateView.set( candidateView.set(
@ -461,7 +460,7 @@ extension VerticalCandidateController {
} }
@objc fileprivate func candidateViewMouseDidClick(_ sender: Any) { @objc fileprivate func candidateViewMouseDidClick(_ sender: Any) {
delegate?.candidateController(self, didSelectCandidateAtIndex: selectedCandidateIndex) delegate?.ctlCandidate(self, didSelectCandidateAtIndex: selectedCandidateIndex)
} }
} }

View File

@ -20,9 +20,9 @@
5B62A33627AE795800A19448 /* mgrPrefs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A33527AE795800A19448 /* mgrPrefs.swift */; }; 5B62A33627AE795800A19448 /* mgrPrefs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A33527AE795800A19448 /* mgrPrefs.swift */; };
5B62A33827AE79CD00A19448 /* NSStringUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A33727AE79CD00A19448 /* NSStringUtils.swift */; }; 5B62A33827AE79CD00A19448 /* NSStringUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A33727AE79CD00A19448 /* NSStringUtils.swift */; };
5B62A33D27AE7CC100A19448 /* ctlAboutWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A33C27AE7CC100A19448 /* ctlAboutWindow.swift */; }; 5B62A33D27AE7CC100A19448 /* ctlAboutWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A33C27AE7CC100A19448 /* ctlAboutWindow.swift */; };
5B62A34627AE7CD900A19448 /* HorizontalCandidateController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A33F27AE7CD900A19448 /* HorizontalCandidateController.swift */; }; 5B62A34627AE7CD900A19448 /* ctlCandidateHorizontal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A33F27AE7CD900A19448 /* ctlCandidateHorizontal.swift */; };
5B62A34727AE7CD900A19448 /* CandidateController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A34027AE7CD900A19448 /* CandidateController.swift */; }; 5B62A34727AE7CD900A19448 /* ctlCandidate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A34027AE7CD900A19448 /* ctlCandidate.swift */; };
5B62A34827AE7CD900A19448 /* VerticalCandidateController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A34127AE7CD900A19448 /* VerticalCandidateController.swift */; }; 5B62A34827AE7CD900A19448 /* ctlCandidateVertical.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A34127AE7CD900A19448 /* ctlCandidateVertical.swift */; };
5B62A34927AE7CD900A19448 /* TooltipController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A34327AE7CD900A19448 /* TooltipController.swift */; }; 5B62A34927AE7CD900A19448 /* TooltipController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A34327AE7CD900A19448 /* TooltipController.swift */; };
5B62A34A27AE7CD900A19448 /* NotifierController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A34527AE7CD900A19448 /* NotifierController.swift */; }; 5B62A34A27AE7CD900A19448 /* NotifierController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A34527AE7CD900A19448 /* NotifierController.swift */; };
5B62A35327AE89C400A19448 /* InputSourceHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A33127AE792F00A19448 /* InputSourceHelper.swift */; }; 5B62A35327AE89C400A19448 /* InputSourceHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A33127AE792F00A19448 /* InputSourceHelper.swift */; };
@ -174,9 +174,9 @@
5B62A33527AE795800A19448 /* mgrPrefs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = mgrPrefs.swift; sourceTree = "<group>"; }; 5B62A33527AE795800A19448 /* mgrPrefs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = mgrPrefs.swift; sourceTree = "<group>"; };
5B62A33727AE79CD00A19448 /* NSStringUtils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSStringUtils.swift; sourceTree = "<group>"; }; 5B62A33727AE79CD00A19448 /* NSStringUtils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSStringUtils.swift; sourceTree = "<group>"; };
5B62A33C27AE7CC100A19448 /* ctlAboutWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ctlAboutWindow.swift; sourceTree = "<group>"; }; 5B62A33C27AE7CC100A19448 /* ctlAboutWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ctlAboutWindow.swift; sourceTree = "<group>"; };
5B62A33F27AE7CD900A19448 /* HorizontalCandidateController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HorizontalCandidateController.swift; sourceTree = "<group>"; }; 5B62A33F27AE7CD900A19448 /* ctlCandidateHorizontal.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ctlCandidateHorizontal.swift; sourceTree = "<group>"; };
5B62A34027AE7CD900A19448 /* CandidateController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CandidateController.swift; sourceTree = "<group>"; }; 5B62A34027AE7CD900A19448 /* ctlCandidate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ctlCandidate.swift; sourceTree = "<group>"; };
5B62A34127AE7CD900A19448 /* VerticalCandidateController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VerticalCandidateController.swift; sourceTree = "<group>"; }; 5B62A34127AE7CD900A19448 /* ctlCandidateVertical.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ctlCandidateVertical.swift; sourceTree = "<group>"; };
5B62A34327AE7CD900A19448 /* TooltipController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TooltipController.swift; sourceTree = "<group>"; }; 5B62A34327AE7CD900A19448 /* TooltipController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TooltipController.swift; sourceTree = "<group>"; };
5B62A34527AE7CD900A19448 /* NotifierController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NotifierController.swift; sourceTree = "<group>"; }; 5B62A34527AE7CD900A19448 /* NotifierController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NotifierController.swift; sourceTree = "<group>"; };
5B707CE527D9F3A10099EF99 /* SwiftyOpenCC */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = SwiftyOpenCC; path = Packages/SwiftyOpenCC; sourceTree = "<group>"; }; 5B707CE527D9F3A10099EF99 /* SwiftyOpenCC */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = SwiftyOpenCC; path = Packages/SwiftyOpenCC; sourceTree = "<group>"; };
@ -505,9 +505,9 @@
5B62A33E27AE7CD900A19448 /* CandidateUI */ = { 5B62A33E27AE7CD900A19448 /* CandidateUI */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
5B62A33F27AE7CD900A19448 /* HorizontalCandidateController.swift */, 5B62A34027AE7CD900A19448 /* ctlCandidate.swift */,
5B62A34027AE7CD900A19448 /* CandidateController.swift */, 5B62A33F27AE7CD900A19448 /* ctlCandidateHorizontal.swift */,
5B62A34127AE7CD900A19448 /* VerticalCandidateController.swift */, 5B62A34127AE7CD900A19448 /* ctlCandidateVertical.swift */,
); );
path = CandidateUI; path = CandidateUI;
sourceTree = "<group>"; sourceTree = "<group>";
@ -984,12 +984,12 @@
5B5E535227EF261400C6AA1E /* IME.swift in Sources */, 5B5E535227EF261400C6AA1E /* IME.swift in Sources */,
5B62A34927AE7CD900A19448 /* TooltipController.swift in Sources */, 5B62A34927AE7CD900A19448 /* TooltipController.swift in Sources */,
6A0D4F4515FC0EB100ABF4B3 /* Mandarin.cpp in Sources */, 6A0D4F4515FC0EB100ABF4B3 /* Mandarin.cpp in Sources */,
5B62A34827AE7CD900A19448 /* VerticalCandidateController.swift in Sources */, 5B62A34827AE7CD900A19448 /* ctlCandidateVertical.swift in Sources */,
6ACC3D452793701600F1B140 /* ParselessLM.cpp in Sources */, 6ACC3D452793701600F1B140 /* ParselessLM.cpp in Sources */,
5BBBB77A27AEDC690023B93A /* clsSFX.swift in Sources */, 5BBBB77A27AEDC690023B93A /* clsSFX.swift in Sources */,
5BF8423127BAA942008E7E4C /* vChewingKanjiConverter.swift in Sources */, 5BF8423127BAA942008E7E4C /* vChewingKanjiConverter.swift in Sources */,
5B62A34627AE7CD900A19448 /* HorizontalCandidateController.swift in Sources */, 5B62A34627AE7CD900A19448 /* ctlCandidateHorizontal.swift in Sources */,
5B62A34727AE7CD900A19448 /* CandidateController.swift in Sources */, 5B62A34727AE7CD900A19448 /* ctlCandidate.swift in Sources */,
D41355DE278EA3ED005E5CBD /* UserPhrasesLM.mm in Sources */, D41355DE278EA3ED005E5CBD /* UserPhrasesLM.mm in Sources */,
6ACC3D3F27914F2400F1B140 /* KeyValueBlobReader.cpp in Sources */, 6ACC3D3F27914F2400F1B140 /* KeyValueBlobReader.cpp in Sources */,
D41355D8278D74B5005E5CBD /* mgrLangModel.mm in Sources */, D41355D8278D74B5005E5CBD /* mgrLangModel.mm in Sources */,