Bug fixes on the marking state.
When the length of the range become to 0, the controller should go back to inputting state.
This commit is contained in:
parent
0ff36cde88
commit
d4173bd931
|
@ -245,8 +245,8 @@ class InputState: NSObject {
|
|||
|
||||
@objc var userPhrase: String {
|
||||
let text = (composingBuffer as NSString).substring(with: markedRange)
|
||||
let exactBegin = (composingBuffer as NSString).nextUtf16Position(for: markedRange.location)
|
||||
let exactEnd = (composingBuffer as NSString).previousUtf16Position(for: markedRange.location)
|
||||
let (exactBegin, _) = (composingBuffer as NSString).characterIndex(from: markedRange.location)
|
||||
let (exactEnd, _) = (composingBuffer as NSString).characterIndex(from: markedRange.location)
|
||||
let readings = readings[exactBegin..<exactEnd]
|
||||
let joined = readings.joined(separator: "-")
|
||||
return "\(text) \(joined)"
|
||||
|
|
|
@ -852,7 +852,13 @@ static NSString *const kGraphVizOutputfile = @"/tmp/McBopomofo-visualization.dot
|
|||
index = [state.composingBuffer previousUtf16PositionFor:index];
|
||||
InputStateMarking *marking = [[InputStateMarking alloc] initWithComposingBuffer:state.composingBuffer cursorIndex:state.cursorIndex markerIndex:index readings:state.readings];
|
||||
marking.tooltipForInputting = state.tooltipForInputting;
|
||||
stateCallback(marking);
|
||||
|
||||
if (marking.markedRange.length == 0) {
|
||||
InputState *inputting = [marking convertToInputting];
|
||||
stateCallback(inputting);
|
||||
} else {
|
||||
stateCallback(marking);
|
||||
}
|
||||
} else {
|
||||
errorCallback();
|
||||
stateCallback(state);
|
||||
|
@ -868,6 +874,12 @@ static NSString *const kGraphVizOutputfile = @"/tmp/McBopomofo-visualization.dot
|
|||
index = [state.composingBuffer nextUtf16PositionFor:index];
|
||||
InputStateMarking *marking = [[InputStateMarking alloc] initWithComposingBuffer:state.composingBuffer cursorIndex:state.cursorIndex markerIndex:index readings:state.readings];
|
||||
marking.tooltipForInputting = state.tooltipForInputting;
|
||||
if (marking.markedRange.length == 0) {
|
||||
InputState *inputting = [marking convertToInputting];
|
||||
stateCallback(inputting);
|
||||
} else {
|
||||
stateCallback(marking);
|
||||
}
|
||||
stateCallback(marking);
|
||||
} else {
|
||||
errorCallback();
|
||||
|
|
Loading…
Reference in New Issue