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