Fixes NSCoding exceptions.
This commit is contained in:
parent
56c393cefa
commit
2bbaa4a793
|
@ -1301,6 +1301,8 @@ static double FindHighestScore(const vector<NodeAnchor> &nodes, double epsilon)
|
|||
|
||||
- (void)handleState:(InputState *)newState client:(id)client
|
||||
{
|
||||
NSLog(@"current state: %@ new state: %@", _state, newState );
|
||||
|
||||
if ([newState isKindOfClass:[InputStateDeactive class]]) {
|
||||
[self _handleInputStateDeactive:(InputStateDeactive *) newState previous:_state client:client];
|
||||
}
|
||||
|
@ -1368,6 +1370,9 @@ static double FindHighestScore(const vector<NodeAnchor> &nodes, double epsilon)
|
|||
{
|
||||
NSString *poppedText = [state poppedText];
|
||||
[self _commitText:poppedText client:client];
|
||||
|
||||
_builder->clear();
|
||||
_walkedNodes.clear();
|
||||
gCurrentCandidateController.visible = NO;
|
||||
[self _hideTooltip];
|
||||
}
|
||||
|
|
|
@ -6,6 +6,9 @@ class InputState: NSObject {
|
|||
|
||||
/// Represents that the input controller is deactive.
|
||||
class InputStateDeactive: InputState {
|
||||
override var description: String {
|
||||
return "<InputStateDeactive>"
|
||||
}
|
||||
}
|
||||
|
||||
/// Represents that the composing buffer is empty.
|
||||
|
@ -20,6 +23,10 @@ class InputStateCommitting: InputState {
|
|||
self.init()
|
||||
self.poppedText = poppedText
|
||||
}
|
||||
|
||||
override var description: String {
|
||||
return "<InputStateCommitting poppedText:\(poppedText)>"
|
||||
}
|
||||
}
|
||||
|
||||
/// Represents that the composing buffer is not empty.
|
||||
|
@ -31,6 +38,10 @@ class InputStateNotEmpty: InputState {
|
|||
self.composingBuffer = composingBuffer
|
||||
self.cursorIndex = cursorIndex
|
||||
}
|
||||
|
||||
override var description: String {
|
||||
return "<InputStateNotEmpty, composingBuffer:\(composingBuffer), cursorIndex:\(cursorIndex)>"
|
||||
}
|
||||
}
|
||||
|
||||
/// Represents that the user is inputting text.
|
||||
|
@ -44,13 +55,16 @@ class InputStateInputting: InputStateNotEmpty {
|
|||
}
|
||||
|
||||
@objc var attributedString: NSAttributedString {
|
||||
let attrs: [NSAttributedString.Key : Any] = [
|
||||
.underlineStyle: NSUnderlineStyle.single,
|
||||
let attributedSting = NSAttributedString(string: composingBuffer, attributes: [
|
||||
.underlineStyle: NSUnderlineStyle.single.rawValue,
|
||||
.markedClauseSegment: 0
|
||||
]
|
||||
let attributedSting = NSAttributedString(string: composingBuffer, attributes: attrs)
|
||||
])
|
||||
return attributedSting
|
||||
}
|
||||
|
||||
override var description: String {
|
||||
return "<InputStateInputting, composingBuffer:\(composingBuffer), cursorIndex:\(cursorIndex), poppedText:\(poppedText)>"
|
||||
}
|
||||
}
|
||||
|
||||
private let kMinMarkRangeLength = 2
|
||||
|
@ -95,20 +109,24 @@ class InputStateMarking: InputStateNotEmpty {
|
|||
@objc var attributedString: NSAttributedString {
|
||||
let attributedSting = NSMutableAttributedString(string: composingBuffer)
|
||||
attributedSting.setAttributes([
|
||||
NSAttributedString.Key.underlineStyle: NSUnderlineStyle.single,
|
||||
NSAttributedString.Key.markedClauseSegment: 0
|
||||
.underlineStyle: NSUnderlineStyle.single.rawValue,
|
||||
.markedClauseSegment: 0
|
||||
], range: NSRange(location: 0, length: markedRange.location))
|
||||
attributedSting.setAttributes([
|
||||
NSAttributedString.Key.underlineStyle: NSUnderlineStyle.single,
|
||||
NSAttributedString.Key.markedClauseSegment: 1
|
||||
.underlineStyle: NSUnderlineStyle.single.rawValue,
|
||||
.markedClauseSegment: 1
|
||||
], range: markedRange)
|
||||
attributedSting.setAttributes([
|
||||
NSAttributedString.Key.underlineStyle: NSUnderlineStyle.single,
|
||||
NSAttributedString.Key.markedClauseSegment: 2
|
||||
.underlineStyle: NSUnderlineStyle.single.rawValue,
|
||||
.markedClauseSegment: 2
|
||||
], range: NSRange(location: markedRange.location + markedRange.length,
|
||||
length: composingBuffer.count - (markedRange.location + markedRange.length) ))
|
||||
return attributedSting
|
||||
}
|
||||
|
||||
override var description: String {
|
||||
return "<InputStateMarking, composingBuffer:\(composingBuffer), cursorIndex:\(cursorIndex), markedRange:\(markedRange), readings:\(readings)>"
|
||||
}
|
||||
}
|
||||
|
||||
/// Represents that the user is choosing in a candidates list.
|
||||
|
@ -123,11 +141,14 @@ class InputStateChoosingCandidate: InputStateNotEmpty {
|
|||
}
|
||||
|
||||
@objc var attributedString: NSAttributedString {
|
||||
let attrs: [NSAttributedString.Key : Any] = [
|
||||
.underlineStyle: NSUnderlineStyle.single,
|
||||
let attributedSting = NSAttributedString(string: composingBuffer, attributes: [
|
||||
.underlineStyle: NSUnderlineStyle.single.rawValue,
|
||||
.markedClauseSegment: 0
|
||||
]
|
||||
let attributedSting = NSAttributedString(string: composingBuffer, attributes: attrs)
|
||||
])
|
||||
return attributedSting
|
||||
}
|
||||
|
||||
override var description: String {
|
||||
return "<InputStateChoosingCandidate, candidates:\(candidates), useVerticalMode:\(useVerticalMode), composingBuffer:\(composingBuffer), cursorIndex:\(cursorIndex)>"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue