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
Add configuration for overriding keyboard layout #526
Conversation
yous
commented
May 21, 2019
OSXCore/TISInputSource.swift
Outdated
return unmanaged.takeRetainedValue() as? [TISInputSource] | ||
} | ||
|
||
func property(forKey key: CFString) -> Any? { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
다른 함수의 관례를 따르면 String이나 NSString을 받고 함수 안에서 변환하는게 좋겠습니다
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kTISProperty...
상수들이 CFString이라 이렇게 뒀는데 String으로 바꾸는 게 나을까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IOKit을 할때는 이렇게 했었네요 https://github.com/gureum/gureum/blob/master/OSXCore/IOKit.swift#L111
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이런 식으로 바꿔봤습니다. 74dbd55
Preferences/Preferences.swift
Outdated
@IBOutlet var romanModeByEscapeKeyButton: NSButton! | ||
@IBOutlet var hangulAutoReorderButton: NSButton! | ||
@IBOutlet var hangulNonChoseongCombinationButton: NSButton! | ||
@IBOutlet var hangulForceStrictCombinationRuleButton: NSButton! | ||
|
||
var configuration = Configuration() | ||
var inputSources: [(identifier: String, localizedName: String)] = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lazy var inputSources: [(identifier: String, localizedName: String)] = {
return loadInputSources()
}()
아니면 그냥 loadInputSources()를 지우고 여기로 옮겨도 좋겠습니다
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
loadInputSources() 안에서 overridingKeyboardNameComboBox.reloadData()
를 호출하는데 closure 안에 있으면 inputSources가 변경되기 전에 호출될 것 같네요. 좋은 방법이 있을까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overridingKeyboardNameComboBox.reloadData()
를 viewDidLoad에 넣으면 어떨까요?
loadInputSources함수를 사이드이펙트 다 없애고 inputSources로 옮기면 reload할때 자연스럽게 inputSources
를 참조하면서 목록을 불러올것 같습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
잘 동작하는 것 같습니다. 64c83dd
Preferences/Preferences.swift
Outdated
if sourceUS != nil && !sources.contains { $0.0 == sourceUS.0 && $0.1 == sourceUS.1 } { | ||
sources.append(sourceUS) | ||
} | ||
sources.sort { $0.localizedName < $1.localizedName } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
US, 활성자판, 비활성자판 순으로 정렬할거면 어차피 전체 자판에서 US가 포함될거고 정렬함수만 잘 만들면 되니까 sourceUS 없이 US layout identifier만 잘 들고 정렬에 쓰면 될것 같아요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gureum.xcodeproj/project.pbxproj
Outdated
@@ -912,6 +913,7 @@ | |||
developmentRegion = English; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이걸 en으로 바꾸면 밑에서 knownRegions에 English가 추가 안될것 같네요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
libhangul-objc도 비슷하게 수정해야 하네요. deprecated language 경고를 수정하면 되는 듯합니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
복병이 여기저기 숨어있었네요 감사합니다
Preferences/Preferences.swift
Outdated
|
||
loadInputSources() | ||
for index in 0 ..< inputSources.count { | ||
if configuration.overridingKeyboardName == inputSources[index].identifier { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if let selectedSource = inputSources.first(where: {$0.identifier == configuration.overridingKeyboardName}) {
...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
firstIndex로 하니 깔끔해졌네요. e22476c
OSXCore/TISInputSource.swift
Outdated
} | ||
|
||
var enabled: Bool { | ||
get { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get {}
없이 코드 블럭이 바로 나오면 getter가 됩니다. swiftformat을 한번 돌리면 자동으로 됩니다. (brew로 받을 수 있습니다)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preferences/Preferences.swift
Outdated
} else if $1.identifier == usIdentifier { | ||
return false | ||
} | ||
if $0.enabled && !$1.enabled { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if $0.enabled != $1.enabled {
return $0.enabled
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#103 도 깔끔하게 해결될듯 합니다 |