mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 19:50:48 +00:00
Made modifications to the NSSpellChecker to use the guesses. The spell checker should function exactly like the one under OPENSTEP now.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@10231 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
fc32db5a61
commit
81ef3324d8
4 changed files with 168 additions and 134 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
||||||
|
2001-06-23 Gregory John Casamento <greg_casamento@yahoo.com
|
||||||
|
* Source/NSSpellChecker.m updated to use the guesses browser.
|
||||||
|
Delegate methods implemented to fill in the guesses for the
|
||||||
|
current misspelled word.
|
||||||
|
|
||||||
|
2001-06-20 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||||
|
* Source/NSSpellChecker.m implementation
|
||||||
|
* Source/NSSpellServer.m implementation
|
||||||
|
* Tools/GSspell.m for the GSspell.service.
|
||||||
|
* Panel/SpellPanel.gmodel also added for the spell checker gui.
|
||||||
|
|
||||||
Sat Jun 16 15:19:29 2001 Nicola Pero <n.pero@mi.flashnet.it>
|
Sat Jun 16 15:19:29 2001 Nicola Pero <n.pero@mi.flashnet.it>
|
||||||
|
|
||||||
* Source/NSCell.m ([-performClick:]): Call setNextState:
|
* Source/NSCell.m ([-performClick:]): Call setNextState:
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
|
|
||||||
Copyright (C) 1996 Free Software Foundation, Inc.
|
Copyright (C) 1996 Free Software Foundation, Inc.
|
||||||
|
|
||||||
Author: Gregory John Casamento <borgheron@yahoo.com>
|
Author: Gregory John Casamento <greg_casamento@yahoo.com>
|
||||||
Date: 2000
|
Date: 2001
|
||||||
|
|
||||||
Author of previous version: Scott Christley <scottc@net-community.com>
|
Author of previous version: Scott Christley <scottc@net-community.com>
|
||||||
Date: 1996
|
Date: 1996
|
||||||
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public
|
You should have received a copy of the GNU Library General Public
|
||||||
License along with this library; see the file COPYING.LIB.
|
License along with this library; see the file COPYING.LIB.
|
||||||
If not, write to the Free Software Foundation,
|
If not, write to the Free Software Foundation,
|
||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
/*
|
/*
|
||||||
NSSpellChecker.m
|
NSSpellChecker.m
|
||||||
|
|
||||||
Description...
|
Class to provide the graphical interface to the spell checking
|
||||||
|
service.
|
||||||
|
|
||||||
Copyright (C) 1996, 2000 Free Software Foundation, Inc.
|
Copyright (C) 2001, 1996 Free Software Foundation, Inc.
|
||||||
|
|
||||||
Author: Gregory John Casamento <greg_casamento@yahoo.com>
|
Author: Gregory John Casamento <greg_casamento@yahoo.com>
|
||||||
Date: 2000
|
Date: 2001
|
||||||
|
|
||||||
Author: Scott Christley <scottc@net-community.com>
|
Author: Scott Christley <scottc@net-community.com>
|
||||||
Date: 1996
|
Date: 1996
|
||||||
|
@ -51,24 +52,26 @@
|
||||||
#include <AppKit/NSScrollView.h>
|
#include <AppKit/NSScrollView.h>
|
||||||
|
|
||||||
// prototype for function to create name for server
|
// prototype for function to create name for server
|
||||||
NSString *GSSpellServerName(NSString *checkerDictionary,
|
NSString *GSSpellServerName(NSString *checkerDictionary, NSString *language);
|
||||||
NSString *language);
|
|
||||||
|
|
||||||
// These are methods which we only want the NSSpellChecker to call.
|
// These are methods which we only want the NSSpellChecker to call.
|
||||||
// The protocol is defined here so that the outside world does not
|
// The protocol is defined here so that the outside world does not
|
||||||
// have access to these internal methods.
|
// have access to these internal methods.
|
||||||
@protocol NSSpellServerPrivateProtocol
|
@protocol NSSpellServerPrivateProtocol
|
||||||
- (NSRange)_findMisspelledWordInString: (NSString *)stringToCheck
|
- (NSRange) _findMisspelledWordInString: (NSString *)stringToCheck
|
||||||
language: (NSString *)language
|
language: (NSString *)language
|
||||||
learnedDictionaries: (NSArray *)dictionaries
|
learnedDictionaries: (NSArray *)dictionaries
|
||||||
wordCount: (int *)wordCount
|
wordCount: (int *)wordCount
|
||||||
countOnly: (BOOL)countOnly;
|
countOnly: (BOOL)countOnly;
|
||||||
-(BOOL)_learnWord: (NSString *)word
|
|
||||||
inDictionary: (NSString *)language;
|
- (BOOL) _learnWord: (NSString *)word
|
||||||
-(BOOL)_forgetWord: (NSString *)word
|
inDictionary: (NSString *)language;
|
||||||
inDictionary: (NSString *)language;
|
|
||||||
- (NSArray *)_suggestGuessesForWord: (NSString *)word
|
- (BOOL) _forgetWord: (NSString *)word
|
||||||
inLanguage: (NSString *)language;
|
inDictionary: (NSString *)language;
|
||||||
|
|
||||||
|
- (NSArray *) _suggestGuessesForWord: (NSString *)word
|
||||||
|
inLanguage: (NSString *)language;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
// Methods needed to get the GSServicesManager
|
// Methods needed to get the GSServicesManager
|
||||||
|
@ -102,7 +105,6 @@ NSString *GSSpellServerName(NSString *checkerDictionary,
|
||||||
NSString *port = GSSpellServerName(vendor, language);
|
NSString *port = GSSpellServerName(vendor, language);
|
||||||
double seconds = 30.0;
|
double seconds = 30.0;
|
||||||
|
|
||||||
NSLog(@"Spell Checker Dictionary: %@", spellCheckers);
|
|
||||||
NSLog(@"Language: %@", language);
|
NSLog(@"Language: %@", language);
|
||||||
NSLog(@"Service to start: %@", spellServicePath);
|
NSLog(@"Service to start: %@", spellServicePath);
|
||||||
NSLog(@"Port: %@",port);
|
NSLog(@"Port: %@",port);
|
||||||
|
@ -119,8 +121,8 @@ NSString *GSSpellServerName(NSString *checkerDictionary,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NSLog(@"Set proxy");
|
NSLog(@"Set proxy");
|
||||||
[(NSDistantObject *)proxy
|
[(NSDistantObject *)proxy setProtocolForProxy:
|
||||||
setProtocolForProxy: @protocol(NSSpellServerPrivateProtocol)];
|
@protocol(NSSpellServerPrivateProtocol)];
|
||||||
}
|
}
|
||||||
|
|
||||||
return proxy;
|
return proxy;
|
||||||
|
@ -185,25 +187,6 @@ static int __documentTag = 0;
|
||||||
//
|
//
|
||||||
// Internal methods for use by the spellChecker GUI
|
// Internal methods for use by the spellChecker GUI
|
||||||
//
|
//
|
||||||
- (void)_populateDictionaryPulldown: (NSArray *)dictionaries;
|
|
||||||
{
|
|
||||||
[_dictionaryPulldown removeAllItems];
|
|
||||||
[_dictionaryPulldown addItemsWithTitles: dictionaries];
|
|
||||||
[_dictionaryPulldown selectItemWithTitle: _language];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)_populateAccessoryView: (NSArray *)words
|
|
||||||
{
|
|
||||||
NSLog(@"Populate accessory view.......... %@", words);
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)_handleServerDeath: (NSNotification *)notification
|
|
||||||
{
|
|
||||||
NSLog(@"Spell server died");
|
|
||||||
RELEASE(_serverProxy);
|
|
||||||
_serverProxy = nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Support function to start the spell server
|
// Support function to start the spell server
|
||||||
- (id)_startServerForLanguage: (NSString *)language
|
- (id)_startServerForLanguage: (NSString *)language
|
||||||
{
|
{
|
||||||
|
@ -243,6 +226,28 @@ static int __documentTag = 0;
|
||||||
return _serverProxy;
|
return _serverProxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)_populateDictionaryPulldown: (NSArray *)dictionaries;
|
||||||
|
{
|
||||||
|
[_dictionaryPulldown removeAllItems];
|
||||||
|
[_dictionaryPulldown addItemsWithTitles: dictionaries];
|
||||||
|
[_dictionaryPulldown selectItemWithTitle: _language];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)_populateAccessoryView
|
||||||
|
{
|
||||||
|
// Make sure that the spell server is up &
|
||||||
|
// refresh the columns in the browser
|
||||||
|
[self _serverProxy];
|
||||||
|
[_accessoryView reloadColumn: 0];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)_handleServerDeath: (NSNotification *)notification
|
||||||
|
{
|
||||||
|
NSLog(@"Spell server died");
|
||||||
|
RELEASE(_serverProxy);
|
||||||
|
_serverProxy = nil;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Instance methods
|
// Instance methods
|
||||||
//
|
//
|
||||||
|
@ -311,10 +316,10 @@ static int __documentTag = 0;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
NSRange r = NSMakeRange(0,0);
|
NSRange r = NSMakeRange(0,0);
|
||||||
r = [[self _serverProxy] _findMisspelledWordInString: aString
|
r = [[self _serverProxy] _findMisspelledWordInString: aString
|
||||||
language: _language
|
language: _language
|
||||||
learnedDictionaries: nil
|
learnedDictionaries: nil
|
||||||
wordCount: &count
|
wordCount: &count
|
||||||
countOnly: YES];
|
countOnly: YES];
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
@ -326,11 +331,11 @@ static int __documentTag = 0;
|
||||||
NSRange r = NSMakeRange(0,0);
|
NSRange r = NSMakeRange(0,0);
|
||||||
|
|
||||||
r = [self checkSpellingOfString: stringToCheck
|
r = [self checkSpellingOfString: stringToCheck
|
||||||
startingAt: startingOffset
|
startingAt: startingOffset
|
||||||
language: _language
|
language: _language
|
||||||
wrap: NO
|
wrap: NO
|
||||||
inSpellDocumentWithTag: 0
|
inSpellDocumentWithTag: 0
|
||||||
wordCount: &wordCount];
|
wordCount: &wordCount];
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -367,10 +372,10 @@ static int __documentTag = 0;
|
||||||
// Get the substring and check it.
|
// Get the substring and check it.
|
||||||
NSString *substringToCheck = [stringToCheck substringFromIndex: startingOffset];
|
NSString *substringToCheck = [stringToCheck substringFromIndex: startingOffset];
|
||||||
r = [[self _serverProxy] _findMisspelledWordInString: substringToCheck
|
r = [[self _serverProxy] _findMisspelledWordInString: substringToCheck
|
||||||
language: _language
|
language: _language
|
||||||
learnedDictionaries: dictForTag
|
learnedDictionaries: dictForTag
|
||||||
wordCount: wordCount
|
wordCount: wordCount
|
||||||
countOnly: NO];
|
countOnly: NO];
|
||||||
|
|
||||||
if(r.length != 0)
|
if(r.length != 0)
|
||||||
{
|
{
|
||||||
|
@ -385,16 +390,16 @@ static int __documentTag = 0;
|
||||||
NSString *firstHalfOfString = [stringToCheck
|
NSString *firstHalfOfString = [stringToCheck
|
||||||
substringToIndex: startingOffset];
|
substringToIndex: startingOffset];
|
||||||
r = [[self _serverProxy] _findMisspelledWordInString: firstHalfOfString
|
r = [[self _serverProxy] _findMisspelledWordInString: firstHalfOfString
|
||||||
language: _language
|
language: _language
|
||||||
learnedDictionaries: dictForTag
|
learnedDictionaries: dictForTag
|
||||||
wordCount: wordCount
|
wordCount: wordCount
|
||||||
countOnly: NO];
|
countOnly: NO];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
misspelledWord = [stringToCheck substringFromRange: r];
|
misspelledWord = [stringToCheck substringFromRange: r];
|
||||||
suggestedWords = [[self _serverProxy] _suggestGuessesForWord: misspelledWord
|
//suggestedWords = [[self _serverProxy] _suggestGuessesForWord: misspelledWord
|
||||||
inLanguage: _language];
|
// inLanguage: _language];
|
||||||
}
|
}
|
||||||
NS_HANDLER
|
NS_HANDLER
|
||||||
{
|
{
|
||||||
|
@ -403,7 +408,7 @@ static int __documentTag = 0;
|
||||||
NS_ENDHANDLER
|
NS_ENDHANDLER
|
||||||
|
|
||||||
[self updateSpellingPanelWithMisspelledWord: misspelledWord];
|
[self updateSpellingPanelWithMisspelledWord: misspelledWord];
|
||||||
[self _populateAccessoryView: suggestedWords];
|
[self _populateAccessoryView];
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -492,6 +497,8 @@ inSpellDocumentWithTag:(int)tag
|
||||||
|
|
||||||
- (void)updateSpellingPanelWithMisspelledWord:(NSString *)word
|
- (void)updateSpellingPanelWithMisspelledWord:(NSString *)word
|
||||||
{
|
{
|
||||||
|
[_ignoreButton setEnabled: YES];
|
||||||
|
[_guessButton setEnabled: NO];
|
||||||
[self setWordFieldStringValue: word];
|
[self setWordFieldStringValue: word];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -553,30 +560,8 @@ inSpellDocumentWithTag:(int)tag
|
||||||
|
|
||||||
- _guess: (id)sender
|
- _guess: (id)sender
|
||||||
{
|
{
|
||||||
NSString *word = [_wordField stringValue];
|
// Fill in the view...
|
||||||
NSArray *guesses = nil;
|
[self _populateAccessoryView];
|
||||||
|
|
||||||
NS_DURING
|
|
||||||
{
|
|
||||||
guesses = [[self _serverProxy] _suggestGuessesForWord: word
|
|
||||||
inLanguage: _language];
|
|
||||||
if(guesses == nil)
|
|
||||||
{
|
|
||||||
NSLog(@"Nil array returned from server");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Fill in the view...
|
|
||||||
[self _populateAccessoryView: guesses];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
NS_HANDLER
|
|
||||||
{
|
|
||||||
NSLog(@"%@",[localException reason]);
|
|
||||||
guesses = nil;
|
|
||||||
}
|
|
||||||
NS_ENDHANDLER
|
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -601,7 +586,7 @@ inSpellDocumentWithTag:(int)tag
|
||||||
id responder = [[[[NSApplication sharedApplication] mainWindow] contentView] documentView];
|
id responder = [[[[NSApplication sharedApplication] mainWindow] contentView] documentView];
|
||||||
|
|
||||||
processed = [responder tryToPerform: @selector(changeSpelling:)
|
processed = [responder tryToPerform: @selector(changeSpelling:)
|
||||||
with: _wordField];
|
with: _wordField];
|
||||||
if(!processed)
|
if(!processed)
|
||||||
{
|
{
|
||||||
NSLog(@"Call to changeSpelling failed. No responder found");
|
NSLog(@"Call to changeSpelling failed. No responder found");
|
||||||
|
@ -638,31 +623,82 @@ inSpellDocumentWithTag:(int)tag
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void) awakeFromNib
|
- _highlightGuess: (id)sender
|
||||||
|
{
|
||||||
|
NSString *selectedGuess = nil;
|
||||||
|
|
||||||
|
selectedGuess = [[_accessoryView selectedCell] stringValue];
|
||||||
|
[_ignoreButton setEnabled: NO];
|
||||||
|
[_guessButton setEnabled: YES];
|
||||||
|
[_wordField setStringValue: selectedGuess];
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) awakeFromNib
|
||||||
{
|
{
|
||||||
[self _populateDictionaryPulldown:
|
[self _populateDictionaryPulldown:
|
||||||
[[NSApp _listener] _languagesForPopUpButton]];
|
[[NSApp _listener] _languagesForPopUpButton]];
|
||||||
[_accessoryView setDelegate: self];
|
[_accessoryView setDelegate: self];
|
||||||
|
[_accessoryView setDoubleAction: @selector(_correct:)];
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation NSSpellChecker(NSBrowserDelegate)
|
@interface NSSpellChecker(SpellBrowserDelegate)
|
||||||
- (BOOL) browser: (NSBrowser*)sender
|
- (BOOL) browser: (NSBrowser*)sender selectRow: (int)row inColumn: (int)column;
|
||||||
selectRow: (int)row
|
|
||||||
inColumn: (int)column
|
- (void) browser: (NSBrowser *)sender createRowsForColumn: (int)column
|
||||||
|
inMatrix: (NSMatrix *)matrix;
|
||||||
|
|
||||||
|
- (NSString*) browser: (NSBrowser*)sender titleOfColumn: (int)column;
|
||||||
|
|
||||||
|
- (void) browser: (NSBrowser *)sender
|
||||||
|
willDisplayCell: (id)cell
|
||||||
|
atRow: (int)row
|
||||||
|
column: (int)column;
|
||||||
|
|
||||||
|
- (BOOL) browser: (NSBrowser *)sender isColumnValid: (int)column;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation NSSpellChecker(SpellBrowserDelegate)
|
||||||
|
- (BOOL) browser: (NSBrowser*)sender selectRow: (int)row inColumn: (int)column
|
||||||
{
|
{
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) browser: (NSBrowser *)sender
|
- (void) browser: (NSBrowser *)sender createRowsForColumn: (int)column
|
||||||
createRowsForColumn: (int)column
|
inMatrix: (NSMatrix *)matrix
|
||||||
inMatrix: (NSMatrix *)matrix
|
|
||||||
{
|
{
|
||||||
NSLog(@"Create rows");
|
NSArray *guesses = nil;
|
||||||
|
NSEnumerator *e = nil;
|
||||||
|
NSString *word = nil;
|
||||||
|
NSBrowserCell *cell= nil;
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
// Make the call to the server to get the guesses.
|
||||||
|
NS_DURING
|
||||||
|
{
|
||||||
|
guesses = [_serverProxy _suggestGuessesForWord: [_wordField stringValue]
|
||||||
|
inLanguage: _language];
|
||||||
|
}
|
||||||
|
NS_HANDLER
|
||||||
|
{
|
||||||
|
NSLog(@"%@",[localException reason]);
|
||||||
|
}
|
||||||
|
NS_ENDHANDLER
|
||||||
|
|
||||||
|
e = [guesses objectEnumerator];
|
||||||
|
while((word = [e nextObject]) != nil)
|
||||||
|
{
|
||||||
|
[matrix insertRow: i withCells: nil];
|
||||||
|
cell = [matrix cellAtRow: i column: 0];
|
||||||
|
[cell setLeaf: YES];
|
||||||
|
i++;
|
||||||
|
[cell setStringValue: word];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString*) browser: (NSBrowser*)sender
|
- (NSString*) browser: (NSBrowser*)sender titleOfColumn: (int)column
|
||||||
titleOfColumn: (int)column
|
|
||||||
{
|
{
|
||||||
return @"Guess";
|
return @"Guess";
|
||||||
}
|
}
|
||||||
|
@ -675,12 +711,9 @@ createRowsForColumn: (int)column
|
||||||
NSLog(@"reached 1....");
|
NSLog(@"reached 1....");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
- (BOOL) browser: (NSBrowser *)sender isColumnValid: (int)column
|
||||||
- (BOOL) browser: (NSBrowser *)sender
|
|
||||||
isColumnValid: (int)column
|
|
||||||
{
|
{
|
||||||
NSLog(@"reached 3....");
|
NSLog(@"reached 3....");
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
/*
|
/*
|
||||||
NSSpellServer.m
|
NSSpellServer.m
|
||||||
|
|
||||||
Description...
|
Class to allow a spell checker to be available to other apps.
|
||||||
|
|
||||||
This class provides a
|
Copyright (C) 2001, 1996 Free Software Foundation, Inc.
|
||||||
|
|
||||||
Copyright (C) 1996 Free Software Foundation, Inc.
|
Author by: Gregory Casamento <greg_casamento@yahoo.com>
|
||||||
|
Date: 2001
|
||||||
|
|
||||||
Author: Scott Christley <scottc@net-community.com>
|
Author: Scott Christley <scottc@net-community.com>
|
||||||
Date: 1996
|
Date: 1996
|
||||||
Rewritten by: Gregory Casamento <borgheron@yahoo.com>
|
|
||||||
Date: 2000
|
|
||||||
|
|
||||||
This file is part of the GNUstep GUI Library.
|
This file is part of the GNUstep GUI Library.
|
||||||
|
|
||||||
|
@ -47,8 +46,8 @@
|
||||||
static NSString *GNU_UserDictionariesDir = @"Dictionaries";
|
static NSString *GNU_UserDictionariesDir = @"Dictionaries";
|
||||||
|
|
||||||
// Function to create name for spell server....
|
// Function to create name for spell server....
|
||||||
NSString *GSSpellServerName(NSString *vendor,
|
NSString*
|
||||||
NSString *language)
|
GSSpellServerName(NSString *vendor, NSString *language)
|
||||||
{
|
{
|
||||||
NSString *serverName = nil;
|
NSString *serverName = nil;
|
||||||
|
|
||||||
|
@ -102,11 +101,9 @@ NSString *GSSpellServerName(NSString *vendor,
|
||||||
connection = [[NSConnection alloc] init];
|
connection = [[NSConnection alloc] init];
|
||||||
if(connection)
|
if(connection)
|
||||||
{
|
{
|
||||||
NSLog(@"Connection created.");
|
|
||||||
RETAIN(connection);
|
RETAIN(connection);
|
||||||
[connection setRootObject: self];
|
[connection setRootObject: self];
|
||||||
result = [connection registerName: serverName];
|
result = [connection registerName: serverName];
|
||||||
if(result) NSLog(@"Registered: %@",serverName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -148,8 +145,7 @@ NSString *GSSpellServerName(NSString *vendor,
|
||||||
NSFileManager *mgr = [NSFileManager defaultManager];
|
NSFileManager *mgr = [NSFileManager defaultManager];
|
||||||
|
|
||||||
// Build the path and try to get the dictionary
|
// Build the path and try to get the dictionary
|
||||||
dirPath = [user_gsroot stringByAppendingPathComponent:
|
dirPath = [user_gsroot stringByAppendingPathComponent: GNU_UserDictionariesDir];
|
||||||
GNU_UserDictionariesDir];
|
|
||||||
path = [dirPath stringByAppendingPathComponent: currentLanguage];
|
path = [dirPath stringByAppendingPathComponent: currentLanguage];
|
||||||
|
|
||||||
if (![mgr fileExistsAtPath: path ])
|
if (![mgr fileExistsAtPath: path ])
|
||||||
|
@ -187,8 +183,8 @@ NSString *GSSpellServerName(NSString *vendor,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NSLog(@"Path = %@", path);
|
NSLog(@"Dictionary path = %@", path);
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
@ -285,8 +281,8 @@ NSString *GSSpellServerName(NSString *vendor,
|
||||||
if(userDict)
|
if(userDict)
|
||||||
{
|
{
|
||||||
result = [self _isWord: word
|
result = [self _isWord: word
|
||||||
inDictionary: userDict
|
inDictionary: userDict
|
||||||
caseSensitive: flag];
|
caseSensitive: flag];
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -321,17 +317,16 @@ NSString *GSSpellServerName(NSString *vendor,
|
||||||
{
|
{
|
||||||
NSMutableSet *set = [self _openUserDictionary: language];
|
NSMutableSet *set = [self _openUserDictionary: language];
|
||||||
[set addObject: word];
|
[set addObject: word];
|
||||||
NSLog(@"learnWord....");
|
|
||||||
|
|
||||||
NS_DURING
|
NS_DURING
|
||||||
{
|
{
|
||||||
[_delegate spellServer: self
|
[_delegate spellServer: self
|
||||||
didLearnWord: word
|
didLearnWord: word
|
||||||
inLanguage: language];
|
inLanguage: language];
|
||||||
}
|
}
|
||||||
NS_HANDLER
|
NS_HANDLER
|
||||||
{
|
{
|
||||||
NSLog(@"Spell server delegate throw exception: %@",
|
NSLog(@"Call to delegate cause the following exception: %@",
|
||||||
[localException reason]);
|
[localException reason]);
|
||||||
}
|
}
|
||||||
NS_ENDHANDLER
|
NS_ENDHANDLER
|
||||||
|
@ -344,18 +339,17 @@ NSString *GSSpellServerName(NSString *vendor,
|
||||||
inDictionary: (NSString *)language
|
inDictionary: (NSString *)language
|
||||||
{
|
{
|
||||||
NSMutableSet *set = [self _openUserDictionary: language];
|
NSMutableSet *set = [self _openUserDictionary: language];
|
||||||
NSLog(@"forgetWord....");
|
|
||||||
[set removeObject: word];
|
[set removeObject: word];
|
||||||
|
|
||||||
NS_DURING
|
NS_DURING
|
||||||
{
|
{
|
||||||
[_delegate spellServer: self
|
[_delegate spellServer: self
|
||||||
didForgetWord: word
|
didForgetWord: word
|
||||||
inLanguage: language];
|
inLanguage: language];
|
||||||
}
|
}
|
||||||
NS_HANDLER
|
NS_HANDLER
|
||||||
{
|
{
|
||||||
NSLog(@"Spell server delegate throw exception: %@",
|
NSLog(@"Call to delegate caused following exception: %@",
|
||||||
[localException reason]);
|
[localException reason]);
|
||||||
}
|
}
|
||||||
NS_ENDHANDLER
|
NS_ENDHANDLER
|
||||||
|
@ -371,9 +365,6 @@ NSString *GSSpellServerName(NSString *vendor,
|
||||||
countOnly: (BOOL)countOnly
|
countOnly: (BOOL)countOnly
|
||||||
{
|
{
|
||||||
NSRange r = NSMakeRange(0,0);
|
NSRange r = NSMakeRange(0,0);
|
||||||
NSLog(@"In _findMispelledWorkInString:....");
|
|
||||||
|
|
||||||
NSLog(@"%@", _delegate);
|
|
||||||
|
|
||||||
if(dictionaries != nil)
|
if(dictionaries != nil)
|
||||||
{
|
{
|
||||||
|
@ -388,10 +379,10 @@ NSString *GSSpellServerName(NSString *vendor,
|
||||||
NS_DURING
|
NS_DURING
|
||||||
{
|
{
|
||||||
r = [_delegate spellServer: self
|
r = [_delegate spellServer: self
|
||||||
findMisspelledWordInString: stringToCheck
|
findMisspelledWordInString: stringToCheck
|
||||||
language: language
|
language: language
|
||||||
wordCount: wordCount
|
wordCount: wordCount
|
||||||
countOnly: countOnly];
|
countOnly: countOnly];
|
||||||
}
|
}
|
||||||
NS_HANDLER
|
NS_HANDLER
|
||||||
{
|
{
|
||||||
|
@ -408,13 +399,12 @@ NSString *GSSpellServerName(NSString *vendor,
|
||||||
{
|
{
|
||||||
NSArray *words = nil;
|
NSArray *words = nil;
|
||||||
|
|
||||||
NSLog(@"Entered suggestGuesses....");
|
|
||||||
// Forward to delegate
|
// Forward to delegate
|
||||||
NS_DURING
|
NS_DURING
|
||||||
{
|
{
|
||||||
words = [_delegate spellServer: self
|
words = [_delegate spellServer: self
|
||||||
suggestGuessesForWord: word
|
suggestGuessesForWord: word
|
||||||
inLanguage: language];
|
inLanguage: language];
|
||||||
}
|
}
|
||||||
NS_HANDLER
|
NS_HANDLER
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue