Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

キーバインド設定でカスタマイズされたものを太字で表示する #218

Merged
merged 1 commit into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions macSKK/KeyBinding.swift
Original file line number Diff line number Diff line change
Expand Up @@ -354,4 +354,9 @@ struct KeyBinding: Identifiable, Hashable {
}
}
}

// デフォルトのキーバインディングと同じキー入力かどうかを返す
var isDefault: Bool {
inputs == Self.defaultKeyBindingSettings.first(where: { $0.action == action })?.inputs
}
}
4 changes: 3 additions & 1 deletion macSKK/Settings/KeyBinding/KeyBindingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ struct KeyBindingView: View {
}
Form {
Table(settingsViewModel.selectedKeyBindingSet.values, selection: $selectingKeyBindingAction) {
TableColumn("Action", value: \.action.localizedAction)
TableColumn("Action") { keyBinding in
Text(keyBinding.action.localizedAction).fontWeight(keyBinding.isDefault ? nil : .bold)
}
TableColumn("Key", value: \.localizedInputs)
}
.contextMenu(forSelectionType: KeyBinding.ID.self) { keyBindingActions in
Expand Down
7 changes: 7 additions & 0 deletions macSKKTests/KeyBindingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,11 @@ final class KeyBindingTests: XCTestCase {
XCTAssertTrue(inputEnter.accepts(event: eventOptionEnter))
XCTAssertFalse(inputEnter.accepts(event: eventLeft))
}

func testIsDefault() {
XCTAssertFalse(KeyBinding(.toggleKana, []).isDefault)
XCTAssertTrue(KeyBinding(.toggleKana, [KeyBinding.Input(key: .character("q"), modifierFlags: [])]).isDefault)
XCTAssertFalse(KeyBinding(.toggleKana, [KeyBinding.Input(key: .character("q"), modifierFlags: [.shift])]).isDefault)
XCTAssertFalse(KeyBinding(.toggleKana, [KeyBinding.Input(key: .character("l"), modifierFlags: [])]).isDefault)
}
}
Loading