UserDef // +useShiftQuestionToCallServiceMenu.

This commit is contained in:
ShikiSuen 2024-02-28 23:48:29 +08:00
parent 5eec7cd604
commit 9411686d03
11 changed files with 50 additions and 5 deletions

View File

@ -333,10 +333,24 @@ extension InputHandler {
} }
} }
// MARK: - Flipping pages by using symbol menu keys (when they are not occupied). // MARK: - Calling Service Menu Key through "Shift+?" (if enabled).
var candidateTextServiceMenuRunning: Bool {
state.node.containsCandidateServices && state.type == .ofSymbolTable
}
serviceMenu: if prefs.useShiftQuestionToCallServiceMenu, input.commonKeyModifierFlags == .shift, input.text == "?" {
if candidateTextServiceMenuRunning { break serviceMenu }
let handled = handleServiceMenuInitiation(
candidateText: highlightedCandidate.value,
reading: highlightedCandidate.keyArray
)
if handled { return true }
}
// MARK: - Flipping pages or Calling Service Menu by the Symbol Menu Key.
if input.isSymbolMenuPhysicalKey { if input.isSymbolMenuPhysicalKey {
let candidateTextServiceMenuRunning = state.node.containsCandidateServices && state.type == .ofSymbolTable
switch input.commonKeyModifierFlags { switch input.commonKeyModifierFlags {
case .shift, [], case .shift, [],
.option where !candidateTextServiceMenuRunning: .option where !candidateTextServiceMenuRunning:

View File

@ -54,10 +54,15 @@ public extension SettingsPanesCocoa {
UserDef.kMoveCursorAfterSelectingCandidate.render(fixWidth: innerContentWidth) UserDef.kMoveCursorAfterSelectingCandidate.render(fixWidth: innerContentWidth)
UserDef.kUseDynamicCandidateWindowOrigin.render(fixWidth: innerContentWidth) UserDef.kUseDynamicCandidateWindowOrigin.render(fixWidth: innerContentWidth)
UserDef.kDodgeInvalidEdgeCandidateCursorPosition.render(fixWidth: innerContentWidth) UserDef.kDodgeInvalidEdgeCandidateCursorPosition.render(fixWidth: innerContentWidth)
UserDef.kUseShiftQuestionToCallServiceMenu
.render(fixWidth: innerContentWidth) { renderable in
renderable.currentControl?.target = self
renderable.currentControl?.action = #selector(self.performCandidateKeysSanityCheck(_:))
}
UserDef.kUseJKtoMoveCompositorCursorInCandidateState UserDef.kUseJKtoMoveCompositorCursorInCandidateState
.render(fixWidth: innerContentWidth) { renderable in .render(fixWidth: innerContentWidth) { renderable in
renderable.currentControl?.target = self renderable.currentControl?.target = self
renderable.currentControl?.action = #selector(self.useJKToMoveBufferCursorDidSet(_:)) renderable.currentControl?.action = #selector(self.performCandidateKeysSanityCheck(_:))
} }
}?.boxed() }?.boxed()
NSView() NSView()
@ -91,7 +96,7 @@ public extension SettingsPanesCocoa {
window.callAlert(title: title.localized, text: explanation.localized) window.callAlert(title: title.localized, text: explanation.localized)
} }
@IBAction func useJKToMoveBufferCursorDidSet(_: NSControl) { @IBAction func performCandidateKeysSanityCheck(_: NSControl) {
// didSet // didSet
PrefMgr.shared.candidateKeys = PrefMgr.shared.candidateKeys PrefMgr.shared.candidateKeys = PrefMgr.shared.candidateKeys
} }

View File

@ -41,6 +41,9 @@ public struct VwrSettingsPaneCandidates: View {
@AppStorage(wrappedValue: false, UserDef.kUseJKtoMoveCompositorCursorInCandidateState.rawValue) @AppStorage(wrappedValue: false, UserDef.kUseJKtoMoveCompositorCursorInCandidateState.rawValue)
private var useJKtoMoveCompositorCursorInCandidateState: Bool private var useJKtoMoveCompositorCursorInCandidateState: Bool
@AppStorage(wrappedValue: true, UserDef.kUseShiftQuestionToCallServiceMenu.rawValue)
public var useShiftQuestionToCallServiceMenu: Bool
@AppStorage(wrappedValue: true, UserDef.kMoveCursorAfterSelectingCandidate.rawValue) @AppStorage(wrappedValue: true, UserDef.kMoveCursorAfterSelectingCandidate.rawValue)
private var moveCursorAfterSelectingCandidate: Bool private var moveCursorAfterSelectingCandidate: Bool
@ -72,6 +75,12 @@ public struct VwrSettingsPaneCandidates: View {
.disabled(useRearCursorMode) .disabled(useRearCursorMode)
} }
UserDef.kDodgeInvalidEdgeCandidateCursorPosition.bind($dodgeInvalidEdgeCandidateCursorPosition).render() UserDef.kDodgeInvalidEdgeCandidateCursorPosition.bind($dodgeInvalidEdgeCandidateCursorPosition).render()
UserDef.kUseShiftQuestionToCallServiceMenu.bind(
$useShiftQuestionToCallServiceMenu.didChange {
// didSet
PrefMgr.shared.candidateKeys = PrefMgr.shared.candidateKeys
}
).render()
UserDef.kUseJKtoMoveCompositorCursorInCandidateState.bind( UserDef.kUseJKtoMoveCompositorCursorInCandidateState.bind(
$useJKtoMoveCompositorCursorInCandidateState.didChange { $useJKtoMoveCompositorCursorInCandidateState.didChange {
// didSet // didSet

View File

@ -134,6 +134,9 @@ import SwiftExtension
@AppProperty(key: UserDef.kUseJKtoMoveCompositorCursorInCandidateState.rawValue, defaultValue: false) @AppProperty(key: UserDef.kUseJKtoMoveCompositorCursorInCandidateState.rawValue, defaultValue: false)
public var useJKtoMoveCompositorCursorInCandidateState: Bool public var useJKtoMoveCompositorCursorInCandidateState: Bool
@AppProperty(key: UserDef.kUseShiftQuestionToCallServiceMenu.rawValue, defaultValue: true)
public var useShiftQuestionToCallServiceMenu: Bool
@AppProperty(key: UserDef.kMoveCursorAfterSelectingCandidate.rawValue, defaultValue: true) @AppProperty(key: UserDef.kMoveCursorAfterSelectingCandidate.rawValue, defaultValue: true)
public dynamic var moveCursorAfterSelectingCandidate: Bool public dynamic var moveCursorAfterSelectingCandidate: Bool

View File

@ -13,7 +13,10 @@ import SwiftExtension
public extension PrefMgr { public extension PrefMgr {
func validate(candidateKeys: String) -> String? { func validate(candidateKeys: String) -> String? {
let excluded = useJKtoMoveCompositorCursorInCandidateState ? "jk" : "" var excluded = ""
if useJKtoMoveCompositorCursorInCandidateState { excluded.append("jk") }
if useShiftQuestionToCallServiceMenu { excluded.append("?") }
excluded.append(IMEApp.isKeyboardJIS ? "_" : "`~")
return CandidateKey.validate(keys: candidateKeys, excluding: excluded) return CandidateKey.validate(keys: candidateKeys, excluding: excluded)
} }
} }

View File

@ -32,6 +32,7 @@ public protocol PrefMgrProtocol {
var shouldAutoReloadUserDataFiles: Bool { get set } var shouldAutoReloadUserDataFiles: Bool { get set }
var useRearCursorMode: Bool { get set } var useRearCursorMode: Bool { get set }
var useJKtoMoveCompositorCursorInCandidateState: Bool { get set } var useJKtoMoveCompositorCursorInCandidateState: Bool { get set }
var useShiftQuestionToCallServiceMenu: Bool { get set }
var moveCursorAfterSelectingCandidate: Bool { get set } var moveCursorAfterSelectingCandidate: Bool { get set }
var dodgeInvalidEdgeCandidateCursorPosition: Bool { get set } var dodgeInvalidEdgeCandidateCursorPosition: Bool { get set }
var useDynamicCandidateWindowOrigin: Bool { get set } var useDynamicCandidateWindowOrigin: Bool { get set }

View File

@ -54,6 +54,7 @@ public enum UserDef: String, CaseIterable, Identifiable {
case kShouldAutoReloadUserDataFiles = "ShouldAutoReloadUserDataFiles" case kShouldAutoReloadUserDataFiles = "ShouldAutoReloadUserDataFiles"
case kUseRearCursorMode = "UseRearCursorMode" case kUseRearCursorMode = "UseRearCursorMode"
case kUseJKtoMoveCompositorCursorInCandidateState = "UseJKtoMoveCompositorCursorInCandidateState" case kUseJKtoMoveCompositorCursorInCandidateState = "UseJKtoMoveCompositorCursorInCandidateState"
case kUseShiftQuestionToCallServiceMenu = "UseShiftQuestionToCallServiceMenu"
case kUseDynamicCandidateWindowOrigin = "UseDynamicCandidateWindowOrigin" case kUseDynamicCandidateWindowOrigin = "UseDynamicCandidateWindowOrigin"
case kUseHorizontalCandidateList = "UseHorizontalCandidateList" case kUseHorizontalCandidateList = "UseHorizontalCandidateList"
case kChooseCandidateUsingSpace = "ChooseCandidateUsingSpace" case kChooseCandidateUsingSpace = "ChooseCandidateUsingSpace"
@ -180,6 +181,7 @@ public extension UserDef {
case .kShouldAutoReloadUserDataFiles: return .bool case .kShouldAutoReloadUserDataFiles: return .bool
case .kUseRearCursorMode: return .bool case .kUseRearCursorMode: return .bool
case .kUseJKtoMoveCompositorCursorInCandidateState: return .bool case .kUseJKtoMoveCompositorCursorInCandidateState: return .bool
case .kUseShiftQuestionToCallServiceMenu: return .bool
case .kUseDynamicCandidateWindowOrigin: return .bool case .kUseDynamicCandidateWindowOrigin: return .bool
case .kUseHorizontalCandidateList: return .bool case .kUseHorizontalCandidateList: return .bool
case .kChooseCandidateUsingSpace: return .bool case .kChooseCandidateUsingSpace: return .bool
@ -344,6 +346,10 @@ public extension UserDef {
shortTitle: "i18n:UserDef.kUseJKtoMoveCompositorCursorInCandidateState.shortTitle", shortTitle: "i18n:UserDef.kUseJKtoMoveCompositorCursorInCandidateState.shortTitle",
description: "i18n:UserDef.kUseJKtoMoveCompositorCursorInCandidateState.description" description: "i18n:UserDef.kUseJKtoMoveCompositorCursorInCandidateState.description"
) )
case .kUseShiftQuestionToCallServiceMenu: return .init(
userDef: self,
shortTitle: "i18n:UserDef.kUseShiftQuestionToCallServiceMenu.shortTitle"
)
case .kUseDynamicCandidateWindowOrigin: return .init( case .kUseDynamicCandidateWindowOrigin: return .init(
userDef: self, shortTitle: "Adjust candidate window location according to current node length" userDef: self, shortTitle: "Adjust candidate window location according to current node length"
) )

View File

@ -250,6 +250,7 @@
"i18n:UserDef.kSpecifyCmdOptCtrlEnterBehavior.shortTitle" = "Command+Option+Ctrl+Enter:"; "i18n:UserDef.kSpecifyCmdOptCtrlEnterBehavior.shortTitle" = "Command+Option+Ctrl+Enter:";
"i18n:UserDef.kUseJKtoMoveCompositorCursorInCandidateState.description" = "⚠︎ This will automatically prevent J and K from being used as candidate keys. Also, this won't work with %quick candidates in cassette mode."; "i18n:UserDef.kUseJKtoMoveCompositorCursorInCandidateState.description" = "⚠︎ This will automatically prevent J and K from being used as candidate keys. Also, this won't work with %quick candidates in cassette mode.";
"i18n:UserDef.kUseJKtoMoveCompositorCursorInCandidateState.shortTitle" = "Use J / K to Move Buffer Cursor While Choosing Candidates"; "i18n:UserDef.kUseJKtoMoveCompositorCursorInCandidateState.shortTitle" = "Use J / K to Move Buffer Cursor While Choosing Candidates";
"i18n:UserDef.kUseShiftQuestionToCallServiceMenu.shortTitle" = "Also use Shift+? to call Service Menu in Candidate Window";
"IBM" = "IBM"; "IBM" = "IBM";
"If disabled, this will insert space instead." = "If disabled, this will insert space instead."; "If disabled, this will insert space instead." = "If disabled, this will insert space instead.";
"If not filling the weight, it will be 0.0, the maximum one. An ideal weight situates in [-9.5, 0], making itself can be captured by the walking algorithm. The exception is -114.514, the disciplinary weight. The walking algorithm will ignore it unless it is the unique result." = "If not filling the weight, it will be 0.0, the maximum one. An ideal weight situates in [-9.5, 0], making itself can be captured by the walking algorithm. The exception is -114.514, the disciplinary weight. The walking algorithm will ignore it unless it is the unique result."; "If not filling the weight, it will be 0.0, the maximum one. An ideal weight situates in [-9.5, 0], making itself can be captured by the walking algorithm. The exception is -114.514, the disciplinary weight. The walking algorithm will ignore it unless it is the unique result." = "If not filling the weight, it will be 0.0, the maximum one. An ideal weight situates in [-9.5, 0], making itself can be captured by the walking algorithm. The exception is -114.514, the disciplinary weight. The walking algorithm will ignore it unless it is the unique result.";

View File

@ -250,6 +250,7 @@
"i18n:UserDef.kSpecifyCmdOptCtrlEnterBehavior.shortTitle" = "Command+Option+Ctrl+Enter:"; "i18n:UserDef.kSpecifyCmdOptCtrlEnterBehavior.shortTitle" = "Command+Option+Ctrl+Enter:";
"i18n:UserDef.kUseJKtoMoveCompositorCursorInCandidateState.description" = "⚠︎ これで「J / K」キーは言選り用キー陣列から自動的に外されます。尚、この機能はカセットモードの「%quick」による早速候補入力状態では利用できません。"; "i18n:UserDef.kUseJKtoMoveCompositorCursorInCandidateState.description" = "⚠︎ これで「J / K」キーは言選り用キー陣列から自動的に外されます。尚、この機能はカセットモードの「%quick」による早速候補入力状態では利用できません。";
"i18n:UserDef.kUseJKtoMoveCompositorCursorInCandidateState.shortTitle" = "候補陳列が見えるとき、「J / K」キーで入力緩衝列のカーソルを移す"; "i18n:UserDef.kUseJKtoMoveCompositorCursorInCandidateState.shortTitle" = "候補陳列が見えるとき、「J / K」キーで入力緩衝列のカーソルを移す";
"i18n:UserDef.kUseShiftQuestionToCallServiceMenu.shortTitle" = "候補陳列ウィンドウで「Shift+?」でもサービスメニューを呼出";
"IBM" = "IBM 配列"; "IBM" = "IBM 配列";
"If disabled, this will insert space instead." = "未チェックの場合、スペースを挿入。"; "If disabled, this will insert space instead." = "未チェックの場合、スペースを挿入。";
"If not filling the weight, it will be 0.0, the maximum one. An ideal weight situates in [-9.5, 0], making itself can be captured by the walking algorithm. The exception is -114.514, the disciplinary weight. The walking algorithm will ignore it unless it is the unique result." = "優先度を記入しなかった場合、最高値「0」はデフォルト値です。理想な優先度の範囲は [-9.5, 0] 以内で、ウォーキング算法に捕まれられます。例外は懲戒値「-114.514」で、優先度を最低に極めた値であり、唯一結果のない場合、ウォーキング算法に無視されます。"; "If not filling the weight, it will be 0.0, the maximum one. An ideal weight situates in [-9.5, 0], making itself can be captured by the walking algorithm. The exception is -114.514, the disciplinary weight. The walking algorithm will ignore it unless it is the unique result." = "優先度を記入しなかった場合、最高値「0」はデフォルト値です。理想な優先度の範囲は [-9.5, 0] 以内で、ウォーキング算法に捕まれられます。例外は懲戒値「-114.514」で、優先度を最低に極めた値であり、唯一結果のない場合、ウォーキング算法に無視されます。";

View File

@ -250,6 +250,7 @@
"i18n:UserDef.kSpecifyCmdOptCtrlEnterBehavior.shortTitle" = "Command+Option+Ctrl+Enter:"; "i18n:UserDef.kSpecifyCmdOptCtrlEnterBehavior.shortTitle" = "Command+Option+Ctrl+Enter:";
"i18n:UserDef.kUseJKtoMoveCompositorCursorInCandidateState.description" = "⚠︎ 这将自动禁止 J / K 键用作选字键。另外,该功能在磁带模式的“%quick”快速选字状态下无效。"; "i18n:UserDef.kUseJKtoMoveCompositorCursorInCandidateState.description" = "⚠︎ 这将自动禁止 J / K 键用作选字键。另外,该功能在磁带模式的“%quick”快速选字状态下无效。";
"i18n:UserDef.kUseJKtoMoveCompositorCursorInCandidateState.shortTitle" = "在选字窗显示时允许以 J / K 键移动组字区游标"; "i18n:UserDef.kUseJKtoMoveCompositorCursorInCandidateState.shortTitle" = "在选字窗显示时允许以 J / K 键移动组字区游标";
"i18n:UserDef.kUseShiftQuestionToCallServiceMenu.shortTitle" = "允许在选字窗内也使用「Shift+?」叫出服务选单";
"IBM" = "IBM 排列"; "IBM" = "IBM 排列";
"If disabled, this will insert space instead." = "取消勾选的话,该按键会插入空格。"; "If disabled, this will insert space instead." = "取消勾选的话,该按键会插入空格。";
"If not filling the weight, it will be 0.0, the maximum one. An ideal weight situates in [-9.5, 0], making itself can be captured by the walking algorithm. The exception is -114.514, the disciplinary weight. The walking algorithm will ignore it unless it is the unique result." = "不填写权重的话预设权重为最高值「0」。理想的权重范围在 [-9.5, 0] 这个闭区间内,可以被爬轨算法自动抓到。例外就是惩戒权重「-114.514」,属于极端降权。这种情况下,除非是唯一结果,否则会被爬轨算法忽略掉。"; "If not filling the weight, it will be 0.0, the maximum one. An ideal weight situates in [-9.5, 0], making itself can be captured by the walking algorithm. The exception is -114.514, the disciplinary weight. The walking algorithm will ignore it unless it is the unique result." = "不填写权重的话预设权重为最高值「0」。理想的权重范围在 [-9.5, 0] 这个闭区间内,可以被爬轨算法自动抓到。例外就是惩戒权重「-114.514」,属于极端降权。这种情况下,除非是唯一结果,否则会被爬轨算法忽略掉。";

View File

@ -250,6 +250,7 @@
"i18n:UserDef.kSpecifyCmdOptCtrlEnterBehavior.shortTitle" = "Command+Option+Ctrl+Enter:"; "i18n:UserDef.kSpecifyCmdOptCtrlEnterBehavior.shortTitle" = "Command+Option+Ctrl+Enter:";
"i18n:UserDef.kUseJKtoMoveCompositorCursorInCandidateState.description" = "⚠︎ 這將自動禁止 J / K 鍵用作選字鍵。另外,該功能在磁帶模式的「%quick」快速選字狀態下無效。"; "i18n:UserDef.kUseJKtoMoveCompositorCursorInCandidateState.description" = "⚠︎ 這將自動禁止 J / K 鍵用作選字鍵。另外,該功能在磁帶模式的「%quick」快速選字狀態下無效。";
"i18n:UserDef.kUseJKtoMoveCompositorCursorInCandidateState.shortTitle" = "在選字窗顯示時允許以 J / K 鍵移動組字區游標"; "i18n:UserDef.kUseJKtoMoveCompositorCursorInCandidateState.shortTitle" = "在選字窗顯示時允許以 J / K 鍵移動組字區游標";
"i18n:UserDef.kUseShiftQuestionToCallServiceMenu.shortTitle" = "允許在選字窗內也使用「Shift+?」叫出服務選單";
"IBM" = "IBM 排列"; "IBM" = "IBM 排列";
"If disabled, this will insert space instead." = "取消勾選的話,該按鍵會插入空格。"; "If disabled, this will insert space instead." = "取消勾選的話,該按鍵會插入空格。";
"If not filling the weight, it will be 0.0, the maximum one. An ideal weight situates in [-9.5, 0], making itself can be captured by the walking algorithm. The exception is -114.514, the disciplinary weight. The walking algorithm will ignore it unless it is the unique result." = "不填寫權重的話預設權重為最高值「0」。理想的權重範圍在 [-9.5, 0] 這個閉區間內,可以被爬軌算法自動抓到。例外就是懲戒權重「-114.514」,屬於極端降權。這種情況下,除非是唯一結果,否則會被爬軌算法忽略掉。"; "If not filling the weight, it will be 0.0, the maximum one. An ideal weight situates in [-9.5, 0], making itself can be captured by the walking algorithm. The exception is -114.514, the disciplinary weight. The walking algorithm will ignore it unless it is the unique result." = "不填寫權重的話預設權重為最高值「0」。理想的權重範圍在 [-9.5, 0] 這個閉區間內,可以被爬軌算法自動抓到。例外就是懲戒權重「-114.514」,屬於極端降權。這種情況下,除非是唯一結果,否則會被爬軌算法忽略掉。";