2001-12-17 16:51:51 +00:00
|
|
|
/** <title>NSSpellChecker</title>
|
1996-05-30 20:03:15 +00:00
|
|
|
|
2001-12-17 16:51:51 +00:00
|
|
|
<abstract>Class to provide the graphical interface to the spell checking
|
|
|
|
service.</abstract>
|
1996-05-30 20:03:15 +00:00
|
|
|
|
2001-06-23 14:11:09 +00:00
|
|
|
Copyright (C) 2001, 1996 Free Software Foundation, Inc.
|
2001-06-21 01:05:11 +00:00
|
|
|
|
2003-07-24 03:45:36 +00:00
|
|
|
Author: Gregory John Casamento <greg_casamento@yahoo.com>
|
|
|
|
Date: 2001,2003
|
1996-05-30 20:03:15 +00:00
|
|
|
|
2001-12-17 16:51:51 +00:00
|
|
|
Author: Scott Christley <scottc@net-community.com>
|
1996-05-30 20:03:15 +00:00
|
|
|
Date: 1996
|
|
|
|
|
|
|
|
This file is part of the GNUstep GUI Library.
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
2007-10-29 21:16:17 +00:00
|
|
|
modify it under the terms of the GNU Lesser General Public
|
1996-05-30 20:03:15 +00:00
|
|
|
License as published by the Free Software Foundation; either
|
2008-06-10 04:01:49 +00:00
|
|
|
version 2 of the License, or (at your option) any later version.
|
2007-10-29 21:16:17 +00:00
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2007-10-29 21:16:17 +00:00
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
1996-05-30 20:03:15 +00:00
|
|
|
|
2007-10-29 21:16:17 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
1996-10-18 17:14:13 +00:00
|
|
|
License along with this library; see the file COPYING.LIB.
|
2007-10-29 21:16:17 +00:00
|
|
|
If not, see <http://www.gnu.org/licenses/> or write to the
|
|
|
|
Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
|
|
|
Boston, MA 02110-1301, USA.
|
1996-05-30 20:03:15 +00:00
|
|
|
*/
|
|
|
|
|
2010-03-30 07:54:04 +00:00
|
|
|
#import "config.h"
|
2009-11-15 18:04:17 +00:00
|
|
|
#import <Foundation/NSArray.h>
|
2010-03-25 09:11:50 +00:00
|
|
|
#import <Foundation/NSBundle.h>
|
|
|
|
#import <Foundation/NSConnection.h>
|
2009-11-15 18:04:17 +00:00
|
|
|
#import <Foundation/NSDictionary.h>
|
2010-03-25 09:11:50 +00:00
|
|
|
#import <Foundation/NSDistantObject.h>
|
2009-11-15 18:04:17 +00:00
|
|
|
#import <Foundation/NSEnumerator.h>
|
2010-03-25 09:11:50 +00:00
|
|
|
#import <Foundation/NSException.h>
|
|
|
|
#import <Foundation/NSNotification.h>
|
2009-11-15 18:04:17 +00:00
|
|
|
#import <Foundation/NSProxy.h>
|
2010-03-25 09:11:50 +00:00
|
|
|
#import <Foundation/NSSet.h>
|
2009-11-15 18:04:17 +00:00
|
|
|
#import <Foundation/NSSpellServer.h>
|
2010-03-25 09:11:50 +00:00
|
|
|
#import <Foundation/NSUserDefaults.h>
|
2009-11-15 18:04:17 +00:00
|
|
|
#import <Foundation/NSValue.h>
|
2010-03-30 07:54:04 +00:00
|
|
|
#import "AppKit/NSBrowser.h"
|
|
|
|
#import "AppKit/NSBrowserCell.h"
|
2009-11-15 18:04:17 +00:00
|
|
|
#import "AppKit/NSEvent.h"
|
2010-03-30 07:54:04 +00:00
|
|
|
#import "AppKit/NSGraphics.h"
|
2009-11-15 18:04:17 +00:00
|
|
|
#import "AppKit/NSImage.h"
|
2010-03-30 07:54:04 +00:00
|
|
|
#import "AppKit/NSMatrix.h"
|
|
|
|
#import "AppKit/NSNib.h"
|
|
|
|
#import "AppKit/NSNibLoading.h"
|
|
|
|
#import "AppKit/NSPanel.h"
|
|
|
|
#import "AppKit/NSPopUpButton.h"
|
2009-11-15 18:04:17 +00:00
|
|
|
#import "AppKit/NSSpellChecker.h"
|
|
|
|
#import "AppKit/NSApplication.h"
|
|
|
|
#import "AppKit/NSTextField.h"
|
|
|
|
#import "AppKit/NSWindow.h"
|
2010-03-30 07:54:04 +00:00
|
|
|
#import "GSGuiPrivate.h"
|
2021-10-18 20:29:50 +00:00
|
|
|
#import "GNUstepBase/NSDebug+GNUstepBase.h"
|
2010-03-30 07:54:04 +00:00
|
|
|
#import "GNUstepGUI/GSServicesManager.h"
|
1996-05-30 20:03:15 +00:00
|
|
|
|
2001-06-21 01:05:11 +00:00
|
|
|
// prototype for function to create name for server
|
2015-01-31 18:19:29 +00:00
|
|
|
extern NSString *GSSpellServerName(NSString *checkerDictionary, NSString *language);
|
2001-06-21 01:05:11 +00:00
|
|
|
|
|
|
|
// These are methods which we only want the NSSpellChecker to call.
|
|
|
|
// The protocol is defined here so that the outside world does not
|
|
|
|
// have access to these internal methods.
|
|
|
|
@protocol NSSpellServerPrivateProtocol
|
2001-06-23 14:11:09 +00:00
|
|
|
- (NSRange) _findMisspelledWordInString: (NSString *)stringToCheck
|
|
|
|
language: (NSString *)language
|
2001-07-24 04:31:06 +00:00
|
|
|
ignoredWords: (NSArray *)ignoredWords
|
2001-06-23 14:11:09 +00:00
|
|
|
wordCount: (int *)wordCount
|
|
|
|
countOnly: (BOOL)countOnly;
|
|
|
|
|
|
|
|
- (BOOL) _learnWord: (NSString *)word
|
|
|
|
inDictionary: (NSString *)language;
|
|
|
|
|
|
|
|
- (BOOL) _forgetWord: (NSString *)word
|
|
|
|
inDictionary: (NSString *)language;
|
|
|
|
|
|
|
|
- (NSArray *) _suggestGuessesForWord: (NSString *)word
|
|
|
|
inLanguage: (NSString *)language;
|
2001-06-21 01:05:11 +00:00
|
|
|
@end
|
|
|
|
|
|
|
|
// Methods needed to get the GSServicesManager
|
|
|
|
@interface NSApplication(NSSpellCheckerMethods)
|
|
|
|
- (GSServicesManager *)_listener;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation NSApplication(NSSpellCheckerMethods)
|
|
|
|
- (GSServicesManager *)_listener
|
|
|
|
{
|
|
|
|
return _listener;
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
// Methods in the GSServicesManager to launch the spell server.
|
|
|
|
@interface GSServicesManager(NSSpellCheckerMethods)
|
|
|
|
- (id)_launchSpellCheckerForLanguage: (NSString *)language;
|
|
|
|
- (NSArray *)_languagesForPopUpButton;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation GSServicesManager(NSSpellCheckerMethods)
|
|
|
|
- (id)_launchSpellCheckerForLanguage: (NSString *)language
|
|
|
|
{
|
2021-10-18 20:29:50 +00:00
|
|
|
if ([[NSUserDefaults standardUserDefaults] boolForKey: @"GSDisableSpellCheckerServer"])
|
|
|
|
{
|
|
|
|
GSOnceMLog(@"WARNING: spell checker disabled - reset 'GSDisableSpellCheckerServer' to NO in defaults to re-enable");
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
2004-06-01 05:51:06 +00:00
|
|
|
id<NSSpellServerPrivateProtocol> proxy = nil;
|
2002-01-06 16:01:02 +00:00
|
|
|
NSDictionary *spellCheckers = [_allServices objectForKey: @"BySpell"];
|
2001-06-21 01:05:11 +00:00
|
|
|
NSDictionary *checkerDictionary = [spellCheckers objectForKey: language];
|
|
|
|
NSString *spellServicePath = [checkerDictionary objectForKey: @"ServicePath"];
|
|
|
|
NSString *vendor = [checkerDictionary objectForKey: @"NSSpellChecker"];
|
|
|
|
NSDate *finishBy;
|
|
|
|
|
|
|
|
NSString *port = GSSpellServerName(vendor, language);
|
|
|
|
double seconds = 30.0;
|
|
|
|
|
|
|
|
NSLog(@"Language: %@", language);
|
|
|
|
NSLog(@"Service to start: %@", spellServicePath);
|
|
|
|
NSLog(@"Port: %@",port);
|
|
|
|
|
|
|
|
finishBy = [NSDate dateWithTimeIntervalSinceNow: seconds];
|
|
|
|
proxy = GSContactApplication(spellServicePath, port, finishBy);
|
|
|
|
if (proxy == nil)
|
|
|
|
{
|
2011-09-07 19:56:36 +00:00
|
|
|
NSLog(@"Failed to contact spell checker for language '%@'", language);
|
2001-06-21 01:05:11 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NSLog(@"Set proxy");
|
2001-06-23 14:11:09 +00:00
|
|
|
[(NSDistantObject *)proxy setProtocolForProxy:
|
|
|
|
@protocol(NSSpellServerPrivateProtocol)];
|
2001-06-21 01:05:11 +00:00
|
|
|
}
|
2021-10-18 20:29:50 +00:00
|
|
|
|
2001-06-21 01:05:11 +00:00
|
|
|
return proxy;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
2001-06-21 01:05:11 +00:00
|
|
|
- (NSArray *)_languagesForPopUpButton
|
|
|
|
{
|
2002-01-06 16:01:02 +00:00
|
|
|
NSDictionary *spellCheckers = [_allServices objectForKey: @"BySpell"];
|
2001-06-21 01:05:11 +00:00
|
|
|
NSArray *allKeys = [spellCheckers allKeys];
|
|
|
|
|
|
|
|
return allKeys;
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
// Shared spell checker instance....
|
|
|
|
static NSSpellChecker *__sharedSpellChecker = nil;
|
|
|
|
static int __documentTag = 0;
|
|
|
|
|
|
|
|
// Implementation of spell checker class
|
|
|
|
@implementation NSSpellChecker
|
1996-05-30 20:03:15 +00:00
|
|
|
//
|
|
|
|
// Class methods
|
|
|
|
//
|
|
|
|
+ (void)initialize
|
|
|
|
{
|
|
|
|
if (self == [NSSpellChecker class])
|
|
|
|
{
|
|
|
|
// Initial version
|
|
|
|
[self setVersion:1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-16 21:12:52 +00:00
|
|
|
+ (BOOL)isAutomaticTextReplacementEnabled
|
|
|
|
{
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
2017-08-17 03:29:14 +00:00
|
|
|
+ (BOOL)isAutomaticDashSubstitutionEnabled
|
|
|
|
{
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
2017-08-17 04:02:45 +00:00
|
|
|
+ (BOOL)isAutomaticQuoteSubstitutionEnabled
|
|
|
|
{
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
//
|
|
|
|
// Making a Checker available
|
|
|
|
//
|
|
|
|
+ (NSSpellChecker *)sharedSpellChecker
|
|
|
|
{
|
2001-06-21 01:05:11 +00:00
|
|
|
// Create the shared instance.
|
2005-11-16 11:34:25 +00:00
|
|
|
if (__sharedSpellChecker == nil)
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
|
|
|
__sharedSpellChecker = [[NSSpellChecker alloc] init];
|
|
|
|
}
|
|
|
|
return __sharedSpellChecker;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
+ (BOOL)sharedSpellCheckerExists
|
|
|
|
{
|
2001-06-21 01:05:11 +00:00
|
|
|
// If the spell checker has been created, the
|
|
|
|
// variable will not be nil.
|
|
|
|
return (__sharedSpellChecker != nil);
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Managing the Spelling Process
|
|
|
|
//
|
|
|
|
+ (int)uniqueSpellDocumentTag
|
|
|
|
{
|
2001-06-21 01:05:11 +00:00
|
|
|
return ++__documentTag;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Internal methods for use by the spellChecker GUI
|
|
|
|
//
|
|
|
|
// Support function to start the spell server
|
|
|
|
- (id)_startServerForLanguage: (NSString *)language
|
|
|
|
{
|
2004-06-01 05:51:06 +00:00
|
|
|
id<NSSpellServerPrivateProtocol> proxy = nil;
|
2001-07-24 04:31:06 +00:00
|
|
|
|
2001-06-21 01:05:11 +00:00
|
|
|
// Start the service for this language
|
|
|
|
proxy = [[NSApp _listener] _launchSpellCheckerForLanguage: language];
|
|
|
|
|
2005-11-16 11:34:25 +00:00
|
|
|
if (proxy == nil)
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
|
|
|
NSLog(@"Failed to get the spellserver");
|
|
|
|
}
|
2001-07-24 04:31:06 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// remove any previous notifications we are observing.
|
|
|
|
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
|
|
|
|
|
|
|
// Make sure that we handle the death of the server correctly.
|
|
|
|
[[NSNotificationCenter defaultCenter]
|
|
|
|
addObserver: self
|
|
|
|
selector: @selector(_handleServerDeath:)
|
|
|
|
name: NSConnectionDidDieNotification
|
|
|
|
object: [(NSDistantObject *)proxy connectionForProxy]];
|
|
|
|
}
|
2001-06-21 01:05:11 +00:00
|
|
|
|
|
|
|
return proxy;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id)_serverProxy
|
|
|
|
{
|
2005-11-16 11:34:25 +00:00
|
|
|
if (_serverProxy == nil)
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
2001-11-03 09:55:32 +00:00
|
|
|
// Start the server and retain the reference to the
|
|
|
|
// proxy.
|
2004-06-01 05:51:06 +00:00
|
|
|
id<NSSpellServerPrivateProtocol> proxy = [self _startServerForLanguage: _language];
|
2005-11-16 11:34:25 +00:00
|
|
|
if (proxy != nil)
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
|
|
|
_serverProxy = proxy;
|
|
|
|
RETAIN(_serverProxy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return _serverProxy;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
2001-12-17 16:51:51 +00:00
|
|
|
- (void)_populateDictionaryPulldown: (NSArray *)dictionaries
|
2001-06-23 14:11:09 +00:00
|
|
|
{
|
|
|
|
[_dictionaryPulldown removeAllItems];
|
2010-02-20 01:27:44 +00:00
|
|
|
[_dictionaryPulldown addItemsWithTitles:
|
|
|
|
[dictionaries sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)]];
|
2001-06-23 14:11:09 +00:00
|
|
|
[_dictionaryPulldown selectItemWithTitle: _language];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)_populateAccessoryView
|
|
|
|
{
|
|
|
|
// refresh the columns in the browser
|
|
|
|
[_accessoryView reloadColumn: 0];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)_handleServerDeath: (NSNotification *)notification
|
|
|
|
{
|
|
|
|
NSLog(@"Spell server died");
|
2001-11-03 09:55:32 +00:00
|
|
|
DESTROY(_serverProxy);
|
2001-06-23 14:11:09 +00:00
|
|
|
}
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
//
|
|
|
|
// Instance methods
|
|
|
|
//
|
2001-06-21 01:05:11 +00:00
|
|
|
- init
|
|
|
|
{
|
2011-03-05 16:18:04 +00:00
|
|
|
NSArray *languages;
|
2001-06-21 01:05:11 +00:00
|
|
|
|
2003-07-24 03:45:36 +00:00
|
|
|
self = [super init];
|
2010-03-30 07:54:04 +00:00
|
|
|
if (self == nil)
|
|
|
|
return nil;
|
|
|
|
|
2011-03-05 16:18:04 +00:00
|
|
|
languages = [[NSUserDefaults standardUserDefaults]
|
|
|
|
stringArrayForKey: @"NSLanguages"];
|
2010-03-30 07:54:04 +00:00
|
|
|
// Set the language to the default for the user.
|
2011-03-13 17:59:31 +00:00
|
|
|
_language = RETAIN([languages objectAtIndex: 0]);
|
2001-06-21 01:05:11 +00:00
|
|
|
_wrapFlag = NO;
|
|
|
|
_position = 0;
|
|
|
|
_spellPanel = nil;
|
|
|
|
_serverProxy = nil;
|
|
|
|
_currentTag = 0;
|
2001-11-03 09:55:32 +00:00
|
|
|
_ignoredWords = [NSMutableDictionary new];
|
2001-06-21 01:05:11 +00:00
|
|
|
|
2010-03-30 07:54:04 +00:00
|
|
|
// Load the NIB file from the GUI bundle
|
|
|
|
if (![GSGuiBundle() loadNibFile: @"GSSpellPanel"
|
|
|
|
externalNameTable: [NSDictionary dictionaryWithObject: self forKey: NSNibOwner]
|
2001-07-31 16:57:26 +00:00
|
|
|
withZone: [self zone]])
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
2003-07-24 03:45:36 +00:00
|
|
|
NSLog(@"Model file load failed for GSSpellPanel");
|
2001-06-21 01:05:11 +00:00
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)dealloc
|
|
|
|
{
|
2011-03-13 17:59:31 +00:00
|
|
|
RELEASE(_language);
|
2001-06-21 01:05:11 +00:00
|
|
|
RELEASE(_ignoredWords);
|
|
|
|
RELEASE(_serverProxy);
|
2003-07-24 03:45:36 +00:00
|
|
|
[super dealloc];
|
2001-06-21 01:05:11 +00:00
|
|
|
}
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
//
|
|
|
|
// Managing the Spelling Panel
|
|
|
|
//
|
|
|
|
- (NSView *)accessoryView
|
|
|
|
{
|
2001-06-21 01:05:11 +00:00
|
|
|
return _accessoryView;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setAccessoryView:(NSView *)aView
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
|
|
|
_accessoryView = aView;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
- (NSPanel *)spellingPanel
|
|
|
|
{
|
2001-06-21 01:05:11 +00:00
|
|
|
return _spellPanel;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
2001-06-21 01:05:11 +00:00
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
//
|
|
|
|
// Checking Spelling
|
|
|
|
//
|
|
|
|
- (int)countWordsInString:(NSString *)aString
|
|
|
|
language:(NSString *)language
|
|
|
|
{
|
2001-06-21 01:05:11 +00:00
|
|
|
int count = 0;
|
2004-06-01 05:51:06 +00:00
|
|
|
id<NSSpellServerPrivateProtocol> proxy = [self _serverProxy];
|
2001-11-03 09:55:32 +00:00
|
|
|
|
|
|
|
if (proxy != nil)
|
2011-03-10 23:21:04 +00:00
|
|
|
[proxy _findMisspelledWordInString: aString
|
|
|
|
language: _language
|
|
|
|
ignoredWords: nil
|
|
|
|
wordCount: &count
|
|
|
|
countOnly: YES];
|
2005-01-21 21:43 Alexander Malmberg <alexander@malmberg.org>
Various whitespace cleanups, comment type fixes, and changes
to avoid warnings from recent versions of gcc.
* Headers/Additions/GNUstepGUI/GSToolbar.h (-_toolbars): Declare.
* Source/NSWindow+Toolbar.m: Remove conflicting declaration of
[NSToolbar -_toolbars].
* Headers/Additions/GNUstepGUI/GSServicesManager.h,
Source/GSServicesMananger.m (-item2title:, -validateMenuItem:):
Adjust argument types.
* Headers/AppKit/NSMenu.h (-validateMenuItem:): Adjust argument
type.
* Source/NSTextView.m (-sizeToFit): Don't use size uninitialized
if neither resizable flags is set.
(-insertText:): Adjust argument type.
* Headers/AppKit/NSResponder.h, Source/NSResponder.m (-insertText:):
Adjust argument type. Document.
* Headers/AppKit/NSView.h: Change type of ivar _window to NSWindow *.
* Source/GSTitleView.m (-mouseDown:): Always initialize
startWindowOrigin.
* Source/NSApplication.m (-setApplicationIconImage:): Add casts
to avoid warnings.
* Source/NSCell.m (-cellSize): Add default: case.
* Source/NSPasteboard.m
([GSFiltered -pasteboard:provideDataForType:]): Detect and warn if we
can't find a filter that will get us the desired type.
* Source/NSProgressIndicator.m: Comment out unused variable 'images'.
* Source/NSBezierPath.m: Declare GSBezierPath fully before using it.
(-bezierPathByFlatteningPath, -bezierPathByReversingPath): Make sure
variables are always initialized.
* Source/NSMenuView.m,
* Source/NSPrintOperation.m,
* Source/NSSplitView.m,
* Source/NSTableHeaderView.m: Make sure variables are always
initialized.
* Source/NSBox.m,
* Source/NSImageview.m,
* Source/NSText.m,
* Source/NSTextStorage.m: Add missing includes.
* Source/GSKeyBindingTable.m,
* Source/GSLayoutManager.m,
* Source/NSBitmapImageRep+PNM.m,
* Source/NSBundleAdditions.m,
* Source/NSLayoutManager.m,
* Source/nsimage-tiff.h,
* Source/tiff.m,
* Headers/Additions/GNUstepGUI/GSDisplayServer.h,
* Source/GSDisplayServer.m: Change signedness of various variables.
* Source/NSPanel.m (-sendEvent:): Remove.
* Source/NSWindow.m (-becomesKeyOnlyIfNeeded): New method.
(-_sendEvent:becomesKeyOnlyIfNeeded:): Remove. Move code ...
(-sendEvent:): ... here. Use -becomesKeyOnlyIfNeeded instead
of the argument.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@20590 72102866-910b-0410-8b05-ffd578937521
2005-01-21 20:39:18 +00:00
|
|
|
|
2001-06-21 01:05:11 +00:00
|
|
|
return count;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSRange)checkSpellingOfString:(NSString *)stringToCheck
|
|
|
|
startingAt:(int)startingOffset
|
|
|
|
{
|
2001-06-21 01:05:11 +00:00
|
|
|
int wordCount = 0;
|
2011-03-10 23:21:04 +00:00
|
|
|
NSRange r;
|
2001-08-03 05:16:49 +00:00
|
|
|
|
2001-06-21 01:05:11 +00:00
|
|
|
r = [self checkSpellingOfString: stringToCheck
|
2001-06-23 14:11:09 +00:00
|
|
|
startingAt: startingOffset
|
|
|
|
language: _language
|
|
|
|
wrap: NO
|
2001-07-24 04:31:06 +00:00
|
|
|
inSpellDocumentWithTag: _currentTag
|
2001-06-23 14:11:09 +00:00
|
|
|
wordCount: &wordCount];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSRange)checkSpellingOfString:(NSString *)stringToCheck
|
|
|
|
startingAt:(int)startingOffset
|
2001-06-21 01:05:11 +00:00
|
|
|
language:(NSString *)language
|
|
|
|
wrap:(BOOL)wrapFlag
|
|
|
|
inSpellDocumentWithTag:(int)tag
|
|
|
|
wordCount:(int *)wordCount
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
2001-11-03 09:55:32 +00:00
|
|
|
NSRange r;
|
2001-07-24 04:31:06 +00:00
|
|
|
NSArray *dictForTag = [self ignoredWordsInSpellDocumentWithTag: tag];
|
2001-06-21 01:05:11 +00:00
|
|
|
|
|
|
|
_currentTag = tag;
|
|
|
|
// We have no string to work with
|
2005-11-16 11:34:25 +00:00
|
|
|
if (stringToCheck == nil)
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
|
|
|
return NSMakeRange(0,0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
// The string is zero length
|
2005-11-16 11:34:25 +00:00
|
|
|
if ([stringToCheck length] == 0)
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
|
|
|
return NSMakeRange(0,0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Do this in an exception handling block in ensure that a failure of the
|
|
|
|
// spellserver does not bring down the application.
|
|
|
|
NS_DURING
|
|
|
|
{
|
2004-06-01 05:51:06 +00:00
|
|
|
id<NSSpellServerPrivateProtocol> proxy = [self _serverProxy];
|
2001-11-03 09:55:32 +00:00
|
|
|
|
2001-06-21 01:05:11 +00:00
|
|
|
// Get the substring and check it.
|
|
|
|
NSString *substringToCheck = [stringToCheck substringFromIndex: startingOffset];
|
2001-11-03 09:55:32 +00:00
|
|
|
if (proxy == nil)
|
|
|
|
NS_VALUERETURN(NSMakeRange(0,0), NSRange);
|
|
|
|
|
|
|
|
r = [proxy _findMisspelledWordInString: substringToCheck
|
|
|
|
language: _language
|
|
|
|
ignoredWords: dictForTag
|
|
|
|
wordCount: wordCount
|
|
|
|
countOnly: NO];
|
2001-06-21 01:05:11 +00:00
|
|
|
|
2005-11-16 11:34:25 +00:00
|
|
|
if (r.length != 0)
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
|
|
|
// Adjust results relative to the original string
|
|
|
|
r.location += startingOffset;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-11-16 11:34:25 +00:00
|
|
|
if (wrapFlag)
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
|
|
|
// Check the second half of the string
|
|
|
|
NSString *firstHalfOfString = [stringToCheck
|
|
|
|
substringToIndex: startingOffset];
|
2001-11-03 09:55:32 +00:00
|
|
|
r = [proxy _findMisspelledWordInString: firstHalfOfString
|
|
|
|
language: _language
|
|
|
|
ignoredWords: dictForTag
|
|
|
|
wordCount: wordCount
|
|
|
|
countOnly: NO];
|
2001-06-21 01:05:11 +00:00
|
|
|
}
|
|
|
|
}
|
2001-11-03 09:55:32 +00:00
|
|
|
NS_VALUERETURN(r, NSRange);
|
2001-06-21 01:05:11 +00:00
|
|
|
}
|
|
|
|
NS_HANDLER
|
|
|
|
{
|
|
|
|
NSLog(@"%@",[localException reason]);
|
|
|
|
}
|
|
|
|
NS_ENDHANDLER
|
|
|
|
|
2001-11-03 09:55:32 +00:00
|
|
|
return NSMakeRange(0,0);
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
2001-11-03 09:55:32 +00:00
|
|
|
- (NSArray *)guessesForWord:(NSString *)word
|
|
|
|
{
|
|
|
|
NSArray *guesses;
|
|
|
|
|
|
|
|
// Make the call to the server to get the guesses.
|
|
|
|
NS_DURING
|
|
|
|
{
|
|
|
|
guesses = [[self _serverProxy] _suggestGuessesForWord: word
|
|
|
|
inLanguage: _language];
|
|
|
|
NS_VALUERETURN(guesses, id);
|
|
|
|
}
|
|
|
|
NS_HANDLER
|
|
|
|
{
|
|
|
|
NSLog(@"%@",[localException reason]);
|
|
|
|
}
|
|
|
|
NS_ENDHANDLER
|
|
|
|
|
|
|
|
return nil;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
2017-08-16 21:19:07 +00:00
|
|
|
- (NSRange)checkGrammarOfString:(NSString *)stringToCheck
|
|
|
|
startingAt:(NSInteger)startingOffset
|
|
|
|
language:(NSString *)language
|
|
|
|
wrap:(BOOL)wrapFlag
|
|
|
|
inSpellDocumentWithTag:(NSInteger)tag
|
|
|
|
details:(NSArray **)details
|
|
|
|
{
|
|
|
|
return NSMakeRange(NSNotFound, 0);
|
|
|
|
}
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
//
|
|
|
|
// Setting the Language
|
|
|
|
//
|
|
|
|
- (NSString *)language
|
|
|
|
{
|
2001-06-21 01:05:11 +00:00
|
|
|
return _language;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)setLanguage:(NSString *)aLanguage
|
|
|
|
{
|
2001-06-21 01:05:11 +00:00
|
|
|
int index = 0;
|
|
|
|
BOOL result = NO;
|
|
|
|
|
|
|
|
index = [_dictionaryPulldown indexOfItemWithTitle: aLanguage];
|
2005-11-16 11:34:25 +00:00
|
|
|
if (index != -1)
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
|
|
|
[_dictionaryPulldown selectItemAtIndex: index];
|
|
|
|
result = YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Managing the Spelling Process
|
|
|
|
//
|
2001-06-21 01:05:11 +00:00
|
|
|
|
|
|
|
// Remove the ignored word list for this
|
|
|
|
// document from the dictionary
|
1996-05-30 20:03:15 +00:00
|
|
|
- (void)closeSpellDocumentWithTag:(int)tag
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
|
|
|
NSNumber *key = [NSNumber numberWithInt: tag];
|
|
|
|
[_ignoredWords removeObjectForKey: key];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
2001-06-21 01:05:11 +00:00
|
|
|
// Add a word to the ignored list.
|
|
|
|
- (void) ignoreWord:(NSString *)wordToIgnore
|
1996-05-30 20:03:15 +00:00
|
|
|
inSpellDocumentWithTag:(int)tag
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
|
|
|
NSNumber *key = [NSNumber numberWithInt: tag];
|
|
|
|
NSMutableSet *words = [_ignoredWords objectForKey: key];
|
|
|
|
|
2005-11-16 11:34:25 +00:00
|
|
|
if (![wordToIgnore isEqualToString: @""])
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
|
|
|
// If there is a dictionary add to it, if not create one.
|
2005-11-16 11:34:25 +00:00
|
|
|
if (words == nil)
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
|
|
|
words = [NSMutableSet setWithObject: wordToIgnore];
|
|
|
|
[_ignoredWords setObject: words forKey: key];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[words addObject: wordToIgnore];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
2001-06-21 01:05:11 +00:00
|
|
|
// get the list of ignored words.
|
1996-05-30 20:03:15 +00:00
|
|
|
- (NSArray *)ignoredWordsInSpellDocumentWithTag:(int)tag
|
|
|
|
{
|
2001-06-21 01:05:11 +00:00
|
|
|
NSNumber *key = [NSNumber numberWithInt: tag];
|
|
|
|
NSSet *words = [_ignoredWords objectForKey: key];
|
|
|
|
return [words allObjects];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
2001-06-21 01:05:11 +00:00
|
|
|
// set the list of ignored words for a given document
|
1996-05-30 20:03:15 +00:00
|
|
|
- (void)setIgnoredWords:(NSArray *)someWords
|
|
|
|
inSpellDocumentWithTag:(int)tag
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
|
|
|
NSNumber *key = [NSNumber numberWithInt: tag];
|
|
|
|
NSSet *words = [NSSet setWithArray: someWords];
|
|
|
|
[_ignoredWords setObject: words forKey: key];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
- (void)setWordFieldStringValue:(NSString *)aString
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
|
|
|
[_wordField setStringValue: aString];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
- (void)updateSpellingPanelWithMisspelledWord:(NSString *)word
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
2001-11-03 09:55:32 +00:00
|
|
|
if ((word == nil) || ([word isEqualToString: @""]))
|
|
|
|
{
|
|
|
|
[_ignoreButton setEnabled: NO];
|
|
|
|
[_guessButton setEnabled: NO];
|
|
|
|
NSBeep();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-06-23 14:11:09 +00:00
|
|
|
[_ignoreButton setEnabled: YES];
|
|
|
|
[_guessButton setEnabled: NO];
|
2001-06-21 01:05:11 +00:00
|
|
|
[self setWordFieldStringValue: word];
|
2001-11-03 09:55:32 +00:00
|
|
|
[self _populateAccessoryView];
|
2001-06-21 01:05:11 +00:00
|
|
|
}
|
|
|
|
|
2011-03-13 18:07:58 +00:00
|
|
|
- (void) _findNext: (id)sender
|
2001-07-24 04:31:06 +00:00
|
|
|
{
|
2010-02-15 11:44:03 +00:00
|
|
|
BOOL processed = [[[NSApp mainWindow] firstResponder]
|
|
|
|
tryToPerform: @selector(checkSpelling:)
|
|
|
|
with: _spellPanel];
|
2001-07-24 04:31:06 +00:00
|
|
|
|
2005-11-16 11:34:25 +00:00
|
|
|
if (!processed)
|
2001-07-24 04:31:06 +00:00
|
|
|
{
|
|
|
|
NSLog(@"No responder found");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-13 18:07:58 +00:00
|
|
|
- (void) _learn: (id)sender
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
|
|
|
NSString *word = [_wordField stringValue];
|
|
|
|
|
|
|
|
// Call server and record the learned word.
|
|
|
|
NS_DURING
|
|
|
|
{
|
2011-03-10 23:21:04 +00:00
|
|
|
[[self _serverProxy] _learnWord: word
|
|
|
|
inDictionary: _language];
|
2001-06-21 01:05:11 +00:00
|
|
|
}
|
|
|
|
NS_HANDLER
|
|
|
|
{
|
|
|
|
NSLog(@"%@",[localException reason]);
|
|
|
|
}
|
|
|
|
NS_ENDHANDLER
|
|
|
|
|
2001-07-24 04:31:06 +00:00
|
|
|
[self _findNext: sender];
|
2001-06-21 01:05:11 +00:00
|
|
|
}
|
|
|
|
|
2011-03-13 18:07:58 +00:00
|
|
|
- (void) _forget: (id)sender
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
|
|
|
NSString *word = [_wordField stringValue];
|
|
|
|
|
|
|
|
// Call the server and remove the word from the learned
|
|
|
|
// list.
|
|
|
|
NS_DURING
|
|
|
|
{
|
2011-02-09 22:20:00 +00:00
|
|
|
[[self _serverProxy] _forgetWord: word
|
|
|
|
inDictionary: _language];
|
2001-06-21 01:05:11 +00:00
|
|
|
}
|
|
|
|
NS_HANDLER
|
|
|
|
{
|
|
|
|
NSLog(@"%@",[localException reason]);
|
|
|
|
}
|
|
|
|
NS_ENDHANDLER
|
|
|
|
|
2001-07-24 04:31:06 +00:00
|
|
|
[self _findNext: sender];
|
2001-06-21 01:05:11 +00:00
|
|
|
}
|
|
|
|
|
2011-03-13 18:07:58 +00:00
|
|
|
- (void) _ignore: (id)sender
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
2010-02-15 11:44:03 +00:00
|
|
|
BOOL processed = [[[NSApp mainWindow] firstResponder]
|
|
|
|
tryToPerform: @selector(ignoreSpelling:)
|
|
|
|
with: _wordField];
|
2001-06-21 01:05:11 +00:00
|
|
|
|
2005-11-16 11:34:25 +00:00
|
|
|
if (!processed)
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
|
|
|
NSLog(@"_ignore: No responder found");
|
|
|
|
}
|
|
|
|
|
2001-07-24 04:31:06 +00:00
|
|
|
[self _findNext: sender];
|
2001-06-21 01:05:11 +00:00
|
|
|
}
|
|
|
|
|
2011-03-13 18:07:58 +00:00
|
|
|
- (void) _guess: (id)sender
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
2001-06-23 14:11:09 +00:00
|
|
|
// Fill in the view...
|
|
|
|
[self _populateAccessoryView];
|
2001-06-21 01:05:11 +00:00
|
|
|
}
|
|
|
|
|
2011-03-13 18:07:58 +00:00
|
|
|
- (void) _correct: (id)sender
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
2010-02-15 11:44:03 +00:00
|
|
|
BOOL processed = [[[NSApp mainWindow] firstResponder]
|
|
|
|
tryToPerform: @selector(changeSpelling:)
|
|
|
|
with: _wordField];
|
2001-06-21 01:05:11 +00:00
|
|
|
|
2005-11-16 11:34:25 +00:00
|
|
|
if (!processed)
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
2001-07-24 04:31:06 +00:00
|
|
|
NSLog(@"No responder found");
|
2001-06-21 01:05:11 +00:00
|
|
|
}
|
2001-07-24 04:31:06 +00:00
|
|
|
[self _findNext: sender];
|
2001-06-21 01:05:11 +00:00
|
|
|
}
|
|
|
|
|
2011-03-13 18:07:58 +00:00
|
|
|
- (void) _switchDictionary: (id)sender
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
2004-06-01 05:51:06 +00:00
|
|
|
id<NSSpellServerPrivateProtocol> proxy = nil;
|
2001-06-21 01:05:11 +00:00
|
|
|
NSString *language = nil;
|
|
|
|
|
|
|
|
// Start the service for this language
|
|
|
|
language = [_dictionaryPulldown stringValue];
|
2005-11-16 11:34:25 +00:00
|
|
|
if (![language isEqualToString: _language])
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
|
|
|
NSLog(@"Language = %@",language);
|
|
|
|
proxy = [self _startServerForLanguage: language];
|
2005-11-16 11:34:25 +00:00
|
|
|
if (proxy != nil)
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
|
|
|
ASSIGN(_language, language);
|
2010-04-10 20:33:30 +00:00
|
|
|
ASSIGN(_serverProxy, (id)proxy);
|
2001-06-21 01:05:11 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Reset the pulldown to the proper language.
|
|
|
|
[_dictionaryPulldown selectItemWithTitle: _language];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-13 18:07:58 +00:00
|
|
|
- (void) _highlightGuess: (id)sender
|
2001-06-23 14:11:09 +00:00
|
|
|
{
|
|
|
|
NSString *selectedGuess = nil;
|
|
|
|
|
|
|
|
selectedGuess = [[_accessoryView selectedCell] stringValue];
|
|
|
|
[_ignoreButton setEnabled: NO];
|
|
|
|
[_guessButton setEnabled: YES];
|
|
|
|
[_wordField setStringValue: selectedGuess];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) awakeFromNib
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
|
|
|
[self _populateDictionaryPulldown:
|
|
|
|
[[NSApp _listener] _languagesForPopUpButton]];
|
|
|
|
[_accessoryView setDelegate: self];
|
2001-06-23 14:11:09 +00:00
|
|
|
[_accessoryView setDoubleAction: @selector(_correct:)];
|
2001-08-03 05:16:49 +00:00
|
|
|
|
|
|
|
[_findNextButton setKeyEquivalent: @"n"];
|
2009-11-15 18:04:17 +00:00
|
|
|
[_findNextButton setKeyEquivalentModifierMask: NSCommandKeyMask];
|
2001-08-03 05:16:49 +00:00
|
|
|
[_ignoreButton setKeyEquivalent: @"i"];
|
2009-11-15 18:04:17 +00:00
|
|
|
[_ignoreButton setKeyEquivalentModifierMask: NSCommandKeyMask];
|
2001-08-03 05:16:49 +00:00
|
|
|
[_learnButton setKeyEquivalent: @"l"];
|
2009-11-15 18:04:17 +00:00
|
|
|
[_learnButton setKeyEquivalentModifierMask: NSCommandKeyMask];
|
2001-08-03 05:16:49 +00:00
|
|
|
[_forgetButton setKeyEquivalent: @"f"];
|
2009-11-15 18:04:17 +00:00
|
|
|
[_forgetButton setKeyEquivalentModifierMask: NSCommandKeyMask];
|
2001-08-03 05:16:49 +00:00
|
|
|
[_guessButton setKeyEquivalent: @"g"];
|
2009-11-15 18:04:17 +00:00
|
|
|
[_guessButton setKeyEquivalentModifierMask: NSCommandKeyMask];
|
2001-08-03 05:16:49 +00:00
|
|
|
[_correctButton setKeyEquivalent: @"c"];
|
2009-11-15 18:04:17 +00:00
|
|
|
[_correctButton setKeyEquivalentModifierMask: NSCommandKeyMask];
|
2001-08-03 05:16:49 +00:00
|
|
|
[_correctButton setImagePosition: NSImageRight];
|
|
|
|
[_correctButton setImage: [NSImage imageNamed: @"common_ret"]];
|
|
|
|
[_correctButton setAlternateImage: [NSImage imageNamed: @"common_retH"]];
|
|
|
|
[_spellPanel makeFirstResponder: _correctButton];
|
2010-02-20 00:38:40 +00:00
|
|
|
[_spellPanel setBecomesKeyOnlyIfNeeded: YES];
|
2010-08-15 20:38:07 +00:00
|
|
|
[_spellPanel setFloatingPanel: YES];
|
2001-06-21 01:05:11 +00:00
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
2001-06-23 14:11:09 +00:00
|
|
|
@interface NSSpellChecker(SpellBrowserDelegate)
|
2013-11-03 16:04:06 +00:00
|
|
|
- (BOOL) browser: (NSBrowser*)sender selectRow: (NSInteger)row inColumn: (NSInteger)column;
|
2001-06-23 14:11:09 +00:00
|
|
|
|
2013-11-03 16:04:06 +00:00
|
|
|
- (void) browser: (NSBrowser *)sender createRowsForColumn: (NSInteger)column
|
2001-06-23 14:11:09 +00:00
|
|
|
inMatrix: (NSMatrix *)matrix;
|
|
|
|
|
2013-11-03 16:04:06 +00:00
|
|
|
- (NSString*) browser: (NSBrowser*)sender titleOfColumn: (NSInteger)column;
|
2001-06-23 14:11:09 +00:00
|
|
|
|
|
|
|
- (void) browser: (NSBrowser *)sender
|
|
|
|
willDisplayCell: (id)cell
|
2013-11-03 16:04:06 +00:00
|
|
|
atRow: (NSInteger)row
|
|
|
|
column: (NSInteger)column;
|
2001-06-23 14:11:09 +00:00
|
|
|
|
2013-11-03 16:04:06 +00:00
|
|
|
- (BOOL) browser: (NSBrowser *)sender isColumnValid: (NSInteger)column;
|
2001-06-23 14:11:09 +00:00
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation NSSpellChecker(SpellBrowserDelegate)
|
2013-11-03 16:04:06 +00:00
|
|
|
- (BOOL) browser: (NSBrowser*)sender selectRow: (NSInteger)row inColumn: (NSInteger)column
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
2013-11-03 16:04:06 +00:00
|
|
|
- (void) browser: (NSBrowser *)sender createRowsForColumn: (NSInteger)column
|
2001-06-23 14:11:09 +00:00
|
|
|
inMatrix: (NSMatrix *)matrix
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
2001-11-03 09:55:32 +00:00
|
|
|
NSArray *guesses = [self guessesForWord: [_wordField stringValue]];
|
|
|
|
NSEnumerator *e = [guesses objectEnumerator];
|
2001-06-23 14:11:09 +00:00
|
|
|
NSString *word = nil;
|
|
|
|
NSBrowserCell *cell= nil;
|
2013-11-03 16:04:06 +00:00
|
|
|
NSInteger i = 0;
|
2001-06-23 14:11:09 +00:00
|
|
|
|
2005-11-16 11:34:25 +00:00
|
|
|
while ((word = [e nextObject]) != nil)
|
2001-06-23 14:11:09 +00:00
|
|
|
{
|
|
|
|
[matrix insertRow: i withCells: nil];
|
|
|
|
cell = [matrix cellAtRow: i column: 0];
|
|
|
|
[cell setLeaf: YES];
|
|
|
|
i++;
|
|
|
|
[cell setStringValue: word];
|
|
|
|
}
|
2001-06-21 01:05:11 +00:00
|
|
|
}
|
|
|
|
|
2013-11-03 16:04:06 +00:00
|
|
|
- (NSString*) browser: (NSBrowser*)sender titleOfColumn: (NSInteger)column
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
2010-03-14 05:45:53 +00:00
|
|
|
return _(@"Guess");
|
2001-06-21 01:05:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) browser: (NSBrowser *)sender
|
|
|
|
willDisplayCell: (id)cell
|
2013-11-03 16:04:06 +00:00
|
|
|
atRow: (NSInteger)row
|
|
|
|
column: (NSInteger)column
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-11-03 16:04:06 +00:00
|
|
|
- (BOOL) browser: (NSBrowser *)sender isColumnValid: (NSInteger)column
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
|
|
|
return NO;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
@end
|