Format ObjC code with clang-format, WebKit style
This commit is contained in:
parent
ca2f4bf8fd
commit
2091c1dc7d
|
@ -29,16 +29,17 @@ extern unsigned short vxSC2TCTable[];
|
|||
const size_t vxTC2SCTableSize = 3059;
|
||||
extern unsigned short vxTC2SCTable[];
|
||||
|
||||
struct VXHCData
|
||||
{
|
||||
struct VXHCData {
|
||||
unsigned short key, value;
|
||||
};
|
||||
|
||||
int VXHCCompare(const void *a, const void *b)
|
||||
{
|
||||
unsigned short x = ((const struct VXHCData *)a)->key, y = ((const struct VXHCData *)b)->key;
|
||||
if (x==y) return 0;
|
||||
if (x<y) return -1;
|
||||
if (x == y)
|
||||
return 0;
|
||||
if (x < y)
|
||||
return -1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -47,7 +48,8 @@ unsigned short VXHCFind(unsigned key, unsigned short *table, size_t size)
|
|||
struct VXHCData k;
|
||||
k.key = key;
|
||||
struct VXHCData *d = (struct VXHCData *)bsearch(&k, table, size, sizeof(struct VXHCData), VXHCCompare);
|
||||
if (!d) return 0;
|
||||
if (!d)
|
||||
return 0;
|
||||
return d->value;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,13 +21,13 @@
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#import "Mandarin.h"
|
||||
#import "KeyHandler.h"
|
||||
#import "Gramambular.h"
|
||||
#import "LanguageModelManager+Privates.h"
|
||||
#import "Mandarin.h"
|
||||
#import "McBopomofo-Swift.h"
|
||||
#import "McBopomofoLM.h"
|
||||
#import "UserOverrideModel.h"
|
||||
#import "LanguageModelManager+Privates.h"
|
||||
#import "KeyHandler.h"
|
||||
#import "McBopomofo-Swift.h"
|
||||
#import <string>
|
||||
|
||||
@import CandidateUI;
|
||||
|
@ -44,7 +44,8 @@ InputMode InputModePlainBopomofo = @"org.openvanilla.inputmethod.McBopomofo.Plai
|
|||
|
||||
static const double kEpsilon = 0.000001;
|
||||
|
||||
static double FindHighestScore(const vector<NodeAnchor> &nodes, double epsilon) {
|
||||
static double FindHighestScore(const vector<NodeAnchor> &nodes, double epsilon)
|
||||
{
|
||||
double highestScore = 0.0;
|
||||
for (auto ni = nodes.begin(), ne = nodes.end(); ni != ne; ++ni) {
|
||||
double score = ni->node->highestUnigramScore();
|
||||
|
@ -56,10 +57,10 @@ static double FindHighestScore(const vector<NodeAnchor> &nodes, double epsilon)
|
|||
}
|
||||
|
||||
// sort helper
|
||||
class NodeAnchorDescendingSorter
|
||||
{
|
||||
class NodeAnchorDescendingSorter {
|
||||
public:
|
||||
bool operator()(const NodeAnchor &a, const NodeAnchor &b) const {
|
||||
bool operator()(const NodeAnchor &a, const NodeAnchor &b) const
|
||||
{
|
||||
return a.node->key().length() > b.node->key().length();
|
||||
}
|
||||
};
|
||||
|
@ -70,9 +71,7 @@ public:
|
|||
static NSString *const kGraphVizOutputfile = @"/tmp/McBopomofo-visualization.dot";
|
||||
#endif
|
||||
|
||||
|
||||
@implementation KeyHandler
|
||||
{
|
||||
@implementation KeyHandler {
|
||||
// the reading buffer that takes user input
|
||||
Formosa::Mandarin::BopomofoReadingBuffer *_bpmfReadingBuffer;
|
||||
|
||||
|
@ -218,8 +217,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/McBopomofo-visualization.dot
|
|||
}
|
||||
[self _walk];
|
||||
|
||||
if (Preferences.selectPhraseAfterCursorAsCandidate &&
|
||||
Preferences.moveCursorAfterSelectingCandidate) {
|
||||
if (Preferences.selectPhraseAfterCursorAsCandidate && Preferences.moveCursorAfterSelectingCandidate) {
|
||||
size_t nextPosition = 0;
|
||||
for (auto node : _walkedNodes) {
|
||||
if (nextPosition >= cursorIndex) {
|
||||
|
@ -260,9 +258,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/McBopomofo-visualization.dot
|
|||
|
||||
// if the composing buffer is empty and there's no reading, and there is some function key combination, we ignore it
|
||||
BOOL isFunctionKey = ([input isCommandHold] || [input isOptionHold] || [input isNumericPad]) || [input isControlHotKey];
|
||||
if (![state isKindOfClass:[InputStateNotEmpty class]] &&
|
||||
![state isKindOfClass:[InputStateAssociatedPhrases class]] &&
|
||||
isFunctionKey) {
|
||||
if (![state isKindOfClass:[InputStateNotEmpty class]] && ![state isKindOfClass:[InputStateAssociatedPhrases class]] && isFunctionKey) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
@ -371,8 +367,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/McBopomofo-visualization.dot
|
|||
NSString *poppedText = [self _popOverflowComposingTextAndWalk];
|
||||
|
||||
// get user override model suggestion
|
||||
string overrideValue = (_inputMode == InputModePlainBopomofo) ? "" :
|
||||
_userOverrideModel->suggest(_walkedNodes, _builder->cursorIndex(), [[NSDate date] timeIntervalSince1970]);
|
||||
string overrideValue = (_inputMode == InputModePlainBopomofo) ? "" : _userOverrideModel->suggest(_walkedNodes, _builder->cursorIndex(), [[NSDate date] timeIntervalSince1970]);
|
||||
|
||||
if (!overrideValue.empty()) {
|
||||
size_t cursorIndex = [self _actualCandidateCursorIndex];
|
||||
|
@ -420,8 +415,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/McBopomofo-visualization.dot
|
|||
// MARK: Space and Down
|
||||
// keyCode 125 = Down, charCode 32 = Space
|
||||
if (_bpmfReadingBuffer->isEmpty() &&
|
||||
[state isKindOfClass:[InputStateNotEmpty class]] &&
|
||||
([input isExtraChooseCandidateKey] || charCode == 32 || (input.useVerticalMode && ([input isVerticalModeOnlyChooseCandidateKey])))) {
|
||||
[state isKindOfClass:[InputStateNotEmpty class]] && ([input isExtraChooseCandidateKey] || charCode == 32 || (input.useVerticalMode && ([input isVerticalModeOnlyChooseCandidateKey])))) {
|
||||
if (charCode == 32) {
|
||||
// if the spacebar is NOT set to be a selection key
|
||||
if ([input isShiftHold] || !Preferences.chooseCandidateUsingSpace) {
|
||||
|
@ -444,7 +438,6 @@ static NSString *const kGraphVizOutputfile = @"/tmp/McBopomofo-visualization.dot
|
|||
stateCallback(inputting);
|
||||
}
|
||||
return YES;
|
||||
|
||||
}
|
||||
}
|
||||
InputStateChoosingCandidate *choosingCandidates = [self _buildCandidateState:(InputStateNotEmpty *)state useVerticalMode:input.useVerticalMode];
|
||||
|
@ -809,7 +802,6 @@ static NSString *const kGraphVizOutputfile = @"/tmp/McBopomofo-visualization.dot
|
|||
return YES;
|
||||
}
|
||||
|
||||
|
||||
- (BOOL)_handleEnterWithState:(InputState *)state stateCallback:(void (^)(InputState *))stateCallback errorCallback:(void (^)(void))errorCallback
|
||||
{
|
||||
if (![state isKindOfClass:[InputStateInputting class]]) {
|
||||
|
@ -863,7 +855,6 @@ static NSString *const kGraphVizOutputfile = @"/tmp/McBopomofo-visualization.dot
|
|||
return YES;
|
||||
}
|
||||
|
||||
|
||||
- (BOOL)_handleMarkingState:(InputStateMarking *)state
|
||||
input:(KeyHandlerInput *)input
|
||||
stateCallback:(void (^)(InputState *))stateCallback
|
||||
|
@ -933,7 +924,6 @@ static NSString *const kGraphVizOutputfile = @"/tmp/McBopomofo-visualization.dot
|
|||
return NO;
|
||||
}
|
||||
|
||||
|
||||
- (BOOL)_handleCandidateState:(InputState *)state
|
||||
input:(KeyHandlerInput *)input
|
||||
stateCallback:(void (^)(InputState *))stateCallback
|
||||
|
@ -950,8 +940,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/McBopomofo-visualization.dot
|
|||
[self clear];
|
||||
InputStateEmptyIgnoringPreviousState *empty = [[InputStateEmptyIgnoringPreviousState alloc] init];
|
||||
stateCallback(empty);
|
||||
}
|
||||
else if (_inputMode == InputModePlainBopomofo) {
|
||||
} else if (_inputMode == InputModePlainBopomofo) {
|
||||
[self clear];
|
||||
InputStateEmptyIgnoringPreviousState *empty = [[InputStateEmptyIgnoringPreviousState alloc] init];
|
||||
stateCallback(empty);
|
||||
|
@ -1143,8 +1132,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/McBopomofo-visualization.dot
|
|||
string customPunctuation = punctuationNamePrefix + layout + string(1, (char)charCode);
|
||||
string punctuation = punctuationNamePrefix + string(1, (char)charCode);
|
||||
|
||||
BOOL shouldAutoSelectCandidate = _bpmfReadingBuffer->isValidKey((char) charCode) || _languageModel->hasUnigramsForKey(customPunctuation) ||
|
||||
_languageModel->hasUnigramsForKey(punctuation);
|
||||
BOOL shouldAutoSelectCandidate = _bpmfReadingBuffer->isValidKey((char)charCode) || _languageModel->hasUnigramsForKey(customPunctuation) || _languageModel->hasUnigramsForKey(punctuation);
|
||||
|
||||
if (!shouldAutoSelectCandidate && (char)charCode >= 'A' && (char)charCode <= 'Z') {
|
||||
string letter = string("_letter_") + string(1, (char)charCode);
|
||||
|
|
|
@ -116,8 +116,7 @@ static void LTLoadAssociatedPhrases(McBopomofoLM &lm)
|
|||
NSString *text = [NSString stringWithUTF8String:input.c_str()];
|
||||
if (Preferences.chineseConversionEngine == 1) {
|
||||
text = [VXHanConvert convertToSimplifiedFrom:text];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
text = [OpenCCBridge convertToSimplified:text];
|
||||
}
|
||||
return string(text.UTF8String);
|
||||
|
|
Loading…
Reference in New Issue