summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--SwifTools/MacOSXChecker.mm10
1 files changed, 9 insertions, 1 deletions
diff --git a/SwifTools/MacOSXChecker.mm b/SwifTools/MacOSXChecker.mm
index 3e687d1..0c73427 100644
--- a/SwifTools/MacOSXChecker.mm
+++ b/SwifTools/MacOSXChecker.mm
@@ -2,20 +2,28 @@
2 * Copyright (c) 2013 Tobias Markmann 2 * Copyright (c) 2013 Tobias Markmann
3 * Licensed under the Simplified BSD license. 3 * Licensed under the Simplified BSD license.
4 * See Documentation/Licenses/BSD-simplified.txt for more information. 4 * See Documentation/Licenses/BSD-simplified.txt for more information.
5 */ 5 */
6 6
7/*
8 * Copyright (c) 2015 Isode Limited.
9 * All rights reserved.
10 * See the COPYING file for more information.
11 */
12
7#include <SwifTools/MacOSXChecker.h> 13#include <SwifTools/MacOSXChecker.h>
8 14
9#include <algorithm> 15#include <algorithm>
10#include <boost/algorithm/string.hpp> 16#include <boost/algorithm/string.hpp>
11 17
12#include <AppKit/AppKit.h> 18#include <AppKit/AppKit.h>
13 19
14namespace Swift { 20namespace Swift {
15 21
16MacOSXChecker::MacOSXChecker() { 22MacOSXChecker::MacOSXChecker() {
23 NSSpellChecker* spellChecker = [NSSpellChecker sharedSpellChecker];
24 [spellChecker setAutomaticallyIdentifiesLanguages:YES];
17} 25}
18 26
19MacOSXChecker::~MacOSXChecker() { 27MacOSXChecker::~MacOSXChecker() {
20} 28}
21 29
@@ -25,11 +33,11 @@ bool MacOSXChecker::isCorrect(const std::string& /*word*/) {
25} 33}
26 34
27void MacOSXChecker::getSuggestions(const std::string& word, std::vector<std::string>& list) { 35void MacOSXChecker::getSuggestions(const std::string& word, std::vector<std::string>& list) {
28 NSSpellChecker* spellChecker = [NSSpellChecker sharedSpellChecker]; 36 NSSpellChecker* spellChecker = [NSSpellChecker sharedSpellChecker];
29 NSString* wordString = [[NSString alloc] initWithUTF8String: word.c_str()]; 37 NSString* wordString = [[NSString alloc] initWithUTF8String: word.c_str()];
30 NSArray* suggestions = [spellChecker guessesForWord: wordString]; 38 NSArray* suggestions = [spellChecker guessesForWordRange:NSMakeRange(0, [wordString length]) inString:wordString language:nil inSpellDocumentWithTag:0];
31 for(unsigned int i = 0; i < [suggestions count]; ++i) { 39 for(unsigned int i = 0; i < [suggestions count]; ++i) {
32 list.push_back(std::string([[suggestions objectAtIndex:i] UTF8String])); 40 list.push_back(std::string([[suggestions objectAtIndex:i] UTF8String]));
33 } 41 }
34 [wordString release]; 42 [wordString release];
35} 43}