Merge branch 'master' of github.com:gnustep/libs-gui

This commit is contained in:
Gregory John Casamento 2020-08-27 19:52:28 -04:00
commit ffee2f9560
17 changed files with 1245 additions and 44 deletions

View file

@ -1,3 +1,25 @@
2020-07-28 Gregory John Casamento <greg.casamento@gmail.com>
* Headers/AppKit/AppKit.h: Add all new headers
* Headers/AppKit/NSTextCheckingClient.h: Protocol for
NSTextCheckingController.m
* Headers/AppKit/NSTextCheckingController.h: New controller
for text checking - spelling/grammar
* Headers/AppKit/NSTextFinder.h: Text finder, currently delegates
all functionality to GSTextFinder.
* Headers/AppKit/NSTextInputClient.h: Protocol
* Headers/AppKit/NSTextInputContext.h: Protocol
* Headers/AppKit/NSTextView.h: Implementation of methods needed
for NSTextFinder.
* Headers/AppKit/NSUserInterfaceValidation.h: Minor changes
* MISSING: Removed these from MISSING list
* Source/GNUmakefile: Add files to be compiled or copied to list.
* Source/NSTextCheckingController.m: Implementation using
NSSpellChecker
* Source/NSTextFinder.m: Implementation using GSTextFinder
* Source/NSTextInputContext.m: Skeleton implementation.
* Source/NSTextView.m: Implementation of methods
2020-08-06 Fred Kiefer <FredKiefer@gmx.de>
* Source/GSStoryboardTransform.h,

View file

@ -246,6 +246,11 @@
#import <AppKit/NSTextAlternatives.h>
#import <AppKit/NSTextAttachment.h>
#import <AppKit/NSTextContainer.h>
#import <AppKit/NSTextCheckingClient.h>
#import <AppKit/NSTextCheckingController.h>
#import <AppKit/NSTextFinder.h>
#import <AppKit/NSTextInputClient.h>
#import <AppKit/NSTextInputContext.h>
#import <AppKit/NSTextList.h>
#import <AppKit/NSTextStorage.h>
#import <AppKit/NSTextTable.h>

View file

@ -0,0 +1,117 @@
/* Definition of class NSTextCheckingClient
Copyright (C) 2020 Free Software Foundation, Inc.
By: Gregory John Casamento
Date: 02-08-2020
This file is part of the GNUstep Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110 USA.
*/
#ifndef _NSTextCheckingClient_h_GNUSTEP_GUI_INCLUDE
#define _NSTextCheckingClient_h_GNUSTEP_GUI_INCLUDE
#import <Foundation/NSObject.h>
#import <Foundation/NSRange.h>
#import <Foundation/NSAttributedString.h>
#import <Foundation/NSGeometry.h>
#import <AppKit/NSTextInputClient.h>
#if OS_API_VERSION(MAC_OS_X_VERSION_10_15, GS_API_LATEST)
#if defined(__cplusplus)
extern "C" {
#endif
enum
{
NSTextInputTraitTypeDefault,
NSTextInputTraitTypeNo,
NSTextInputTraitTypeYes
};
typedef NSInteger NSTextInputTraitType;
@class NSDictionary, NSCandidateListTouchBarItem;
@protocol NSTextInputTraits
#if GS_PROTOCOLS_HAVE_OPTIONAL
@optional
#endif
- (NSTextInputTraitType) autocorrectionType;
- (void) setAutocorrectionType: (NSTextInputTraitType)type;
- (NSTextInputTraitType) spellCheckingType;
- (void) setSpellCheckingType: (NSTextInputTraitType)type;
- (NSTextInputTraitType) grammarCheckingType;
- (void) setGrammarCheckingType: (NSTextInputTraitType)type;
- (NSTextInputTraitType) smartQuotesType;
- (void) setSmartQuotesType: (NSTextInputTraitType)type;
- (NSTextInputTraitType) smartDashesType;
- (void) setSmartDashesType: (NSTextInputTraitType)type;
- (NSTextInputTraitType) smartInsertDeleteType;
- (void) setSmartInsertDeleteType: (NSTextInputTraitType)type;
- (NSTextInputTraitType) textReplacementType;
- (void) setTextReplacementType: (NSTextInputTraitType)type;
- (NSTextInputTraitType) dataDetectionType;
- (void) setDataDetectionType: (NSTextInputTraitType)type;
- (NSTextInputTraitType) linkDetectionType;
- (void) setLinkDetectionType: (NSTextInputTraitType)type;
- (NSTextInputTraitType) textCompletionType;
- (void) setTextCompletionType: (NSTextInputTraitType)type;
@end
@protocol NSTextCheckingClient <NSTextInputClient, NSTextInputTraits>
#if GS_PROTOCOLS_HAVE_OPTIONAL
@required
#endif
- (void) addAnnotations: (NSDictionary *)annotations
range: (NSRange)range;
- (NSAttributedString *) annotatedSubstringForProposedRange: (NSRange)range
actualRange: (NSRangePointer)actualRange;
- (NSCandidateListTouchBarItem *) candidateListTouchBarItem;
- (void) removeAnnotation: (NSAttributedStringKey)annotationName
range: (NSRange)range;
- (void) replaceCharactersInRange: (NSRange)range
withAnnotatedString: (NSAttributedString *)annotatedString;
- (void) selectAndShowRange: (NSRange)range;
- (void) setAnnotations: (NSDictionary *)annotations
range: (NSRange)range;
- (NSView *) viewForRange: (NSRange)range
firstRect: (NSRectPointer)firstRect
actualRange: (NSRangePointer)actualRange;
@end
#if defined(__cplusplus)
}
#endif
#endif /* GS_API_MACOSX */
#endif /* _NSTextCheckingClient_h_GNUSTEP_GUI_INCLUDE */

View file

@ -0,0 +1,86 @@
/* Interface of class NSTextCheckingController
Copyright (C) 2020 Free Software Foundation, Inc.
By: Gregory John Casamento
Date: 02-08-2020
This file is part of the GNUstep Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110 USA.
*/
#ifndef _NSTextCheckingController_h_GNUSTEP_GUI_INCLUDE
#define _NSTextCheckingController_h_GNUSTEP_GUI_INCLUDE
#import <Foundation/NSObject.h>
#import <Foundation/NSRange.h>
#import <AppKit/NSTextCheckingClient.h>
#if OS_API_VERSION(MAC_OS_X_VERSION_10_15, GS_API_LATEST)
#if defined(__cplusplus)
extern "C" {
#endif
@class NSArray, NSDictionary, NSMenu;
@interface NSTextCheckingController : NSObject
{
id<NSTextCheckingClient> _client;
NSInteger _spellCheckerDocumentTag;
}
// initializer
- (instancetype) initWithClient: (id<NSTextCheckingClient>)client;
// properties...
- (id<NSTextCheckingClient>) client;
- (NSInteger) spellCheckerDocumentTag;
- (void) setSpellCheckerDocumentTag: (NSInteger)tag;
// instance methods...
- (void) changeSpelling: (id)sender;
- (void) checkSpelling: (id)sender;
- (void) checkTextInRange: (NSRange)range
types: (NSTextCheckingTypes)checkingTypes
options: (NSDictionary *)options;
- (void) checkTextInSelection: (id)sender;
- (void) checkTextInDocument: (id)sender;
- (void) didChangeTextInRange: (NSRange)range;
- (void) considerTextCheckingForRange: (NSRange)range;
- (void) didChangeSelectedRange;
- (void) ignoreSpelling: (id)sender;
- (void) insertedTextInRange: (NSRange)range;
- (void) invalidate;
- (NSMenu *) menuAtIndex: (NSUInteger)location
clickedOnSelection: (BOOL)clickedOnSelection
effectiveRange: (NSRangePointer)effectiveRange;
- (void) orderFrontSubstitutionsPanel: (id)sender;
- (void) showGuessPanel: (id)sender;
- (void) updateCandidates;
- (NSArray *) validAnnotations;
@end
#if defined(__cplusplus)
}
#endif
#endif /* GS_API_MACOSX */
#endif /* _NSTextCheckingController_h_GNUSTEP_GUI_INCLUDE */

View file

@ -0,0 +1,167 @@
/* Interface of class NSTextFinder
Copyright (C) 2020 Free Software Foundation, Inc.
By: Gregory John Casamento
Date: 02-08-2020
This file is part of the GNUstep Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110 USA.
*/
#ifndef _NSTextFinder_h_GNUSTEP_GUI_INCLUDE
#define _NSTextFinder_h_GNUSTEP_GUI_INCLUDE
#import <Foundation/NSObject.h>
#import <Foundation/NSRange.h>
#import <Foundation/NSGeometry.h>
#import <AppKit/AppKitDefines.h>
#import <AppKit/NSNibDeclarations.h>
#if OS_API_VERSION(MAC_OS_X_VERSION_10_7, GS_API_LATEST)
#if defined(__cplusplus)
extern "C" {
#endif
@class NSArray, NSView;
@protocol NSTextFinderClient, NSTextFinderBarContainer;
enum
{
NSTextFinderActionShowFindInterface = 1,
NSTextFinderActionNextMatch,
NSTextFinderActionPreviousMatch,
NSTextFinderActionReplaceAll,
NSTextFinderActionReplace,
NSTextFinderActionReplaceAndFind,
NSTextFinderActionSetSearchString,
NSTextFinderActionReplaceAllInSelection,
NSTextFinderActionSelectAll,
NSTextFinderActionSelectAllInSelection,
NSTextFinderActionHideFindInterface,
NSTextFinderActionShowReplaceInterface,
NSTextFinderActionHideReplaceInterface
};
typedef NSInteger NSTextFinderAction;
enum
{
NSTextFinderMatchingTypeContains = 0,
NSTextFinderMatchingTypeStartsWith,
NSTextFinderMatchingTypeFullWord,
NSTextFinderMatchingTypeEndsWith
};
typedef NSInteger NSTextFinderMatchingType;
typedef NSString* NSPasteboardTypeTextFinderOptionKey;
APPKIT_EXPORT NSPasteboardTypeTextFinderOptionKey const NSTextFinderCaseInsensitiveKey;
APPKIT_EXPORT NSPasteboardTypeTextFinderOptionKey const NSTextFinderMatchingTypeKey;
@interface NSTextFinder : NSObject <NSCoding>
{
IBOutlet id<NSTextFinderClient> _client;
IBOutlet id<NSTextFinderBarContainer> _findBarContainer;
BOOL _findIndicatorNeedsUpdate;
BOOL _incrementalSearchingEnabled;
BOOL _incrementalSearchingShouldDimContentView;
NSArray *_incrementalMatchRanges;
id _finder;
NSInteger _tag;
}
// Validating and performing
- (void) performAction: (NSTextFinderAction)op;
- (BOOL) validateAction: (NSTextFinderAction)op;
- (void) cancelFindIndicator;
// Properties
- (id<NSTextFinderClient>) client;
- (void) setClient: (id<NSTextFinderClient>) client;
- (id<NSTextFinderBarContainer>) findBarContainer;
- (void) setFindBarContainer: (id<NSTextFinderBarContainer>) findBarContainer;
- (BOOL) findIndicatorNeedsUpdate;
- (void) setFindIndicatorNeedsUpdate: (BOOL)flag;
- (BOOL) isIncrementalSearchingEnabled;
- (void) setIncrementalSearchingEnabled: (BOOL)flag;
- (BOOL) incrementalSearchingShouldDimContentView;
- (void) setIncrementalSearchingShouldDimContentView: (BOOL)flag;
- (NSArray *) incrementalMatchRanges;
+ (void) drawIncrementalMatchHighlightInRect: (NSRect)rect;
- (void) noteClientStringWillChange;
@end
// PROTOCOLS
@protocol NSTextFinderClient <NSObject>
#if GS_PROTOCOLS_HAVE_OPTIONAL
@optional
#endif
- (BOOL) isSelectable;
- (BOOL) allowsMultipleSelection;
- (BOOL) isEditable;
- (NSString *) string;
- (NSString *) stringAtIndex: (NSUInteger)characterIndex
effectiveRange: (NSRangePointer)outRange
endsWithSearchBoundary: (BOOL *)outFlag;
- (NSUInteger) stringLength;
- (NSRange) firstSelectedRange;
- (NSArray *) selectedRanges;
- (void) setSelectedRanges: (NSArray *)ranges;
- (void) scrollRangeToVisible:(NSRange)range;
- (BOOL) shouldReplaceCharactersInRanges: (NSArray *)ranges withStrings: (NSArray *)strings;
- (void) replaceCharactersInRange: (NSRange)range withString: (NSString *)string;
- (void) didReplaceCharacters;
- (NSView *) contentViewAtIndex: (NSUInteger)index effectiveCharacterRange: (NSRangePointer)outRange;
- (NSArray *) rectsForCharacterRange: (NSRange)range;
- (NSArray *) visibleCharacterRanges;
- (void) drawCharactersInRange: (NSRange)range forContentView: (NSView *)view;
@end
@protocol NSTextFinderBarContainer <NSObject>
#if GS_PROTOCOLS_HAVE_OPTIONAL
@required
#endif
- (NSView *) findBarView;
- (void) setFindBarView: (NSView *)view;
- (BOOL) isfindBarVisible;
- (void) setFindBarVisible: (BOOL)flag;
- (void) findBarViewDidChangeHeight;
#if GS_PROTOCOLS_HAVE_OPTIONAL
@optional
#endif
- (NSView *) contentView;
@end
#if defined(__cplusplus)
}
#endif
#endif /* GS_API_MACOSX */
#endif /* _NSTextFinder_h_GNUSTEP_GUI_INCLUDE */

View file

@ -0,0 +1,89 @@
/* Definition of class NSTextInputClient
Copyright (C) 2020 Free Software Foundation, Inc.
By: Gregory John Casamento
Date: 02-08-2020
This file is part of the GNUstep Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110 USA.
*/
#ifndef _NSTextInputClient_h_GNUSTEP_GUI_INCLUDE
#define _NSTextInputClient_h_GNUSTEP_GUI_INCLUDE
#import <Foundation/NSObject.h>
#import <Foundation/NSGeometry.h>
#import <AppKit/NSAttributedString.h>
#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST)
#if defined(__cplusplus)
extern "C" {
#endif
@class NSArray;
@protocol NSTextInputClient
#if GS_PROTOCOLS_HAVE_OPTIONAL
@required
#endif
// Marked text
- (BOOL) hasMarkedText;
- (NSRange) markedRange;
- (NSRange) selectedRange;
- (void) setMarkedText: (id)string
selectedRange: (NSRange)selectedRange
replacementRange: (NSRange)replacementRange;
- (void)unmarkText;
- (NSArray *)validAttributesForMarkedText;
// Storing text
- (NSAttributedString *) attributedSubstringForProposedRange: (NSRange)range
actualRange: (NSRangePointer)actualRange;
- (void) insertText: (id)string
replacementRange: (NSRange)replacementRange;
// Getting Character coordinates
- (NSUInteger) characterIndexForPoint: (NSPoint)point;
- (NSRect) firstRectForCharacterRange: (NSRange)range
actualRange: (NSRangePointer)actualRange;
// Binding keystrokes
- (void) doCommandBySelector: (SEL)selector;
#if GS_PROTOCOLS_HAVE_OPTIONAL
@optional
#endif
// Optional methods
- (NSAttributedString *) attributedString;
- (CGFloat) fractionOfDistanceThroughGlyphForPoint: (NSPoint)point;
- (CGFloat) baselineDeltaForCharacterAtIndex: (NSUInteger)anIndex;
- (NSInteger) windowLevel;
- (BOOL) drawsVerticallyForCharacterAtIndex: (NSUInteger)charIndex;
@end
#if defined(__cplusplus)
}
#endif
#endif /* GS_API_MACOSX */
#endif /* _NSTextInputClient_h_GNUSTEP_GUI_INCLUDE */

View file

@ -0,0 +1,88 @@
/* Interface of class NSTextInputContext
Copyright (C) 2020 Free Software Foundation, Inc.
By: Gregory John Casamento
Date: 02-08-2020
This file is part of the GNUstep Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110 USA.
*/
#ifndef _NSTextInputContext_h_GNUSTEP_GUI_INCLUDE
#define _NSTextInputContext_h_GNUSTEP_GUI_INCLUDE
#import <Foundation/NSObject.h>
#import <AppKit/NSTextInputClient.h>
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST)
#if defined(__cplusplus)
extern "C" {
#endif
@class NSArray, NSString;
typedef NSString* NSTextInputSourceIdentifier;
@interface NSTextInputContext : NSObject
{
id<NSTextInputClient> _client;
BOOL _acceptsGlyphInfo;
NSArray *_allowedInputSourceLocales;
NSArray *_keyboardInputSources;
NSTextInputSourceIdentifier _selectedKeyboardInputSource;
}
+ (NSTextInputContext *) currentInputContext;
- (instancetype) initWithClient: (id<NSTextInputClient>)client;
- (id<NSTextInputClient>) client;
- (BOOL) acceptsGlyphInfo;
- (void) setAcceptsGlyphInfo: (BOOL)flag;
- (NSArray *) allowedInputSourceLocales;
- (void) setAllowedInputSourceLocales: (NSArray *)locales;
- (void) activate;
- (void) deactivate;
- (BOOL) handleEvent: (NSEvent *)event;
- (void) discardMarkedText;
- (void) invalidateCharacterCoordinates;
- (NSArray *) keyboardInputSources;
- (NSTextInputSourceIdentifier) selectedKeyboardInputSource;
+ (NSString *) localizedNameForInputSource:(NSTextInputSourceIdentifier)inputSourceIdentifier;
@end
APPKIT_EXPORT NSNotificationName NSTextInputContextKeyboardSelectionDidChangeNotification;
#if defined(__cplusplus)
}
#endif
#endif /* GS_API_MACOSX */
#endif /* _NSTextInputContext_h_GNUSTEP_GUI_INCLUDE */

View file

@ -34,6 +34,7 @@
#import <GNUstepBase/GSVersionMacros.h>
#import <AppKit/NSText.h>
#import <AppKit/NSTextFinder.h>
#import <AppKit/NSInputManager.h>
#import <AppKit/NSDragging.h>
#import <AppKit/NSTextAttachment.h>
@ -92,7 +93,7 @@ be stored in the NSTextView. Non-persistant attributes don't, and should
therefore be stored in the NSLayoutManager to avoid problems.
*/
@interface NSTextView : NSText <NSTextInput, NSUserInterfaceValidations>
@interface NSTextView : NSText <NSTextInput, NSUserInterfaceValidations, NSTextFinderClient>
{
/* These attributes are shared by all text views attached to a layout
manager. Any changes must be replicated in all those text views. */

View file

@ -41,6 +41,7 @@
@protocol NSUserInterfaceValidations
- (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem;
@end
#endif // _GNUstep_H_NSUserInterfaceValidation

36
MISSING
View file

@ -17,47 +17,11 @@ MISSING HEADERS ( * = difficult, - = quick, + = placeholder )
> NSItemProvider.h +
> NSMenuToolbarItem.h -
> NSOpenGLLayer.h
> NSRuleEditor.h *
> NSStackView.h *
> NSTableCellView.h *
> NSTableRowView.h *
> NSTableViewRowAction.h *
> NSTextCheckingClient.h +
> NSTextCheckingController.h +
> NSTextFinder.h +
> NSTextInputClient.h +
> NSTextInputContext.h +
> NSTypesetter.h +
> NSUserActivity.h -
> NSWindowTab.h +
> NSWindowTabGroup.h +
Mac Specific
---
> NSButtonTouchBarItem.h
> NSCandidateListTouchBarItem.h
> NSColorPickerTouchBarItem.h
> NSCustomTouchBarItem.h
> NSGroupTouchBarItem.h
> NSPickerTouchBarItem.h
> NSPopoverTouchBarItem.h
> NSSharingServicePickerTouchBarItem.h
> NSSliderTouchBarItem.h
> NSStepperTouchBarItem.h
> NSTouchBarItem.h
> NSClickGestureRecognizer.h
> NSMagnificationGestureRecognizer.h
> NSPanGestureRecognizer.h
> NSPressGestureRecognizer.h
> NSRotationGestureRecognizer.h
> NSApplicationScripting.h
> NSDocumentScripting.h
> NSTextStorageScripting.h
> NSWindowScripting.h
> NSHapticFeedback.h
> NSAppleScriptExtensions.h
> NSAlignmentFeedbackFilter.h
> NSTouch.h
> NSTouchBar.h
> NSQuickDrawView.h
> NSPressureConfiguration.h

View file

@ -263,8 +263,11 @@ NSTextAlternatives.m \
NSTextAttachment.m \
NSTextBlock.m \
NSTextContainer.m \
NSTextCheckingController.m \
NSTextField.m \
NSTextFieldCell.m \
NSTextFinder.m \
NSTextInputContext.m \
NSTextList.m \
NSTextStorage.m \
NSTextTable.m \
@ -558,8 +561,13 @@ NSText.h \
NSTextAlternatives.h \
NSTextAttachment.h \
NSTextContainer.h \
NSTextCheckingClient.h \
NSTextCheckingController.h \
NSTextField.h \
NSTextFieldCell.h \
NSTextFinder.h \
NSTextInputClient.h \
NSTextInputContext.h \
NSTextList.h \
NSTextStorage.h \
NSTextTable.h \

View file

@ -57,6 +57,7 @@
}
else
{
[aCoder encodeObject: _rowTemplates];
}
}
@ -76,6 +77,9 @@
}
else
{
NSArray *rowTemplates = [aDecoder decodeObject];
[self setRowTemplates: rowTemplates];
}
return self;

View file

@ -0,0 +1,150 @@
/* Implementation of class NSTextCheckingController
Copyright (C) 2020 Free Software Foundation, Inc.
By: Gregory John Casamento
Date: 02-08-2020
This file is part of the GNUstep Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110 USA.
*/
#import "AppKit/NSTextCheckingController.h"
#import "AppKit/NSSpellChecker.h"
/*
@interface NSSpellChecker (Private)
- (void) _findNext: (id)sender;
- (void) _ignore: (id)sender;
- (void) _guess: (id)sender;
- (void) _correct: (id)sender;
- (void) _switchDictionary: (id)sender;
- (void) _highlightGuess: (id)sender;
@end
*/
@implementation NSTextCheckingController
// initializer
- (instancetype) initWithClient: (id<NSTextCheckingClient>)client
{
self = [super init];
if (self != nil)
{
_client = client;
_spellCheckerDocumentTag = 0;
}
return self;
}
// properties...
- (id<NSTextCheckingClient>) client
{
return _client;
}
- (NSInteger) spellCheckerDocumentTag
{
return _spellCheckerDocumentTag;
}
- (void) setSpellCheckerDocumentTag: (NSInteger)tag
{
_spellCheckerDocumentTag = tag;
}
// instance methods...
- (void) changeSpelling: (id)sender
{
}
- (void) checkSpelling: (id)sender
{
/*
int wordCount = 0;
[[NSSpellChecker sharedSpellChecker] checkSpellingOfString: [_client string]
startingAt: 0
language: nil
wrap: NO
inSpellDocumentWithTag: _spellCheckerDocumentTag
wordCount: &wordCount];*/
}
- (void) checkTextInRange: (NSRange)range
types: (NSTextCheckingTypes)checkingTypes
options: (NSDictionary *)options
{
}
- (void) checkTextInSelection: (id)sender
{
}
- (void) checkTextInDocument: (id)sender
{
}
- (void) didChangeTextInRange: (NSRange)range
{
}
- (void) considerTextCheckingForRange: (NSRange)range
{
}
- (void) didChangeSelectedRange
{
}
- (void) ignoreSpelling: (id)sender
{
}
- (void) insertedTextInRange: (NSRange)range
{
}
- (void) invalidate
{
}
- (NSMenu *) menuAtIndex: (NSUInteger)location
clickedOnSelection: (BOOL)clickedOnSelection
effectiveRange: (NSRangePointer)effectiveRange
{
return nil;
}
- (void) orderFrontSubstitutionsPanel: (id)sender
{
}
- (void) showGuessPanel: (id)sender
{
}
- (void) updateCandidates
{
}
- (NSArray *) validAnnotations
{
return nil;
}
@end

273
Source/NSTextFinder.m Normal file
View file

@ -0,0 +1,273 @@
/* Implementation of class NSTextFinder
Copyright (C) 2020 Free Software Foundation, Inc.
By: Gregory John Casamento
Date: 02-08-2020
This file is part of the GNUstep Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110 USA.
*/
#import <Foundation/NSArray.h>
#import <Foundation/NSArchiver.h>
#import "AppKit/NSTextFinder.h"
#import "AppKit/NSTextView.h"
#import "AppKit/NSUserInterfaceValidation.h"
#import "GSTextFinder.h"
@implementation NSTextFinder
- (instancetype) init
{
self = [super init];
if (self != nil)
{
// initialize finder...
_finder = [[GSTextFinder alloc] init];
}
return self;
}
// Validating and performing
- (void) performFindPanelAction: (id)sender
{
[self performAction: [sender tag]];
}
- (void) performTextFinderAction: (id)sender
{
[self performFindPanelAction: sender];
}
- (NSInteger) tag
{
return _tag;
}
- (void) _mapOpToTag: (NSTextFinderAction)op
{
switch (op)
{
case NSTextFinderActionShowFindInterface:
_tag = NSFindPanelActionShowFindPanel;
break;
case NSTextFinderActionNextMatch:
_tag = NSFindPanelActionNext;
break;
case NSTextFinderActionPreviousMatch:
_tag = NSFindPanelActionPrevious;
break;
case NSTextFinderActionReplaceAll:
_tag = NSFindPanelActionReplaceAll;
break;
case NSTextFinderActionReplace:
_tag = NSFindPanelActionReplace;
break;
case NSTextFinderActionReplaceAndFind:
_tag = NSFindPanelActionReplaceAndFind;
break;
case NSTextFinderActionSetSearchString:
_tag = NSFindPanelActionSetFindString;
break;
case NSTextFinderActionReplaceAllInSelection:
_tag = NSFindPanelActionReplaceAllInSelection;
break;
case NSTextFinderActionSelectAll:
_tag = NSFindPanelActionSelectAll;
break;
case NSTextFinderActionSelectAllInSelection:
_tag = NSFindPanelActionSelectAllInSelection;
break;
case NSTextFinderActionHideFindInterface:
// unsupported;
break;
case NSTextFinderActionShowReplaceInterface:
// unsupported;
break;
case NSTextFinderActionHideReplaceInterface:
// unsupported;
break;
default:
NSLog(@"Unknown operation: %ld", op);
break;
}
}
- (void) performAction: (NSTextFinderAction)op
{
[self _mapOpToTag: op];
[_finder performFindPanelAction: self];
}
- (BOOL) validateUserInterfaceAction: (id<NSValidatedUserInterfaceItem>)item
{
SEL action = [item action];
if (sel_isEqual(action, @selector(performTextFinderAction:)) ||
sel_isEqual(action, @selector(performFindPanelAction:)))
{
return [self validateAction: [item tag]];
}
return YES;
}
- (BOOL) validateAction: (NSTextFinderAction)op
{
[self _mapOpToTag: op];
return [_finder validateFindPanelAction: self
withTextView: nil];
}
- (void)cancelFindIndicator;
{
}
// Properties
- (id<NSTextFinderClient>) client
{
return _client;
}
- (void) setClient: (id<NSTextFinderClient>) client
{
_client = client;
}
- (id<NSTextFinderBarContainer>) findBarContainer
{
return _findBarContainer;
}
- (void) setFindBarContainer: (id<NSTextFinderBarContainer>) findBarContainer
{
_findBarContainer = findBarContainer;
}
- (BOOL) findIndicatorNeedsUpdate
{
return _findIndicatorNeedsUpdate;
}
- (void) setFindIndicatorNeedsUpdate: (BOOL)flag
{
_findIndicatorNeedsUpdate = flag;
}
- (BOOL) isIncrementalSearchingEnabled
{
return _incrementalSearchingEnabled;
}
- (void) setIncrementalSearchingEnabled: (BOOL)flag
{
_incrementalSearchingEnabled = flag;
}
- (BOOL) incrementalSearchingShouldDimContentView
{
return _incrementalSearchingShouldDimContentView;
}
- (void) setIncrementalSearchingShouldDimContentView: (BOOL)flag
{
_incrementalSearchingShouldDimContentView = flag;
}
- (NSArray *) incrementalMatchRanges
{
return _incrementalMatchRanges;
}
+ (void) drawIncrementalMatchHighlightInRect: (NSRect)rect
{
}
- (void) noteClientStringWillChange
{
// nothing...
}
// NSCoding...
- (instancetype) initWithCoder: (NSCoder *)coder
{
self = [super init];
if (self != nil)
{
if ([coder allowsKeyedCoding])
{
if ([coder containsValueForKey: @"NSFindIndicatorNeedsUpdate"])
{
_findIndicatorNeedsUpdate = [coder decodeBoolForKey: @"NSFindIndicatorNeedsUpdate"];
}
if ([coder containsValueForKey: @"NSIncrementalSearchingEnabled"])
{
_incrementalSearchingEnabled = [coder decodeBoolForKey: @"NSIncrementalSearchingEnabled"];
}
if ([coder containsValueForKey: @"NSIncrementalSearchingShouldDimContentView"])
{
_incrementalSearchingShouldDimContentView = [coder decodeBoolForKey: @"NSIncrementalSearchingShouldDimContentView"];
}
if ([coder containsValueForKey: @"NSIncrementalMatchRanges"])
{
ASSIGN(_incrementalMatchRanges, [coder decodeObjectForKey: @"NSIncrementalMatchRanges"]);
}
// initialize finder...
_finder = [GSTextFinder sharedTextFinder];
}
else
{
[coder decodeValueOfObjCType: @encode(BOOL)
at: &_findIndicatorNeedsUpdate];
[coder decodeValueOfObjCType: @encode(BOOL)
at: &_incrementalSearchingEnabled];
[coder decodeValueOfObjCType: @encode(BOOL)
at: &_incrementalSearchingShouldDimContentView];
ASSIGN(_incrementalMatchRanges, [coder decodeObject]);
}
}
return self;
}
- (void) encodeWithCoder: (NSCoder *)coder
{
if ([coder allowsKeyedCoding])
{
[coder encodeBool: _findIndicatorNeedsUpdate
forKey: @"NSFindIndicatorNeedsUpdate"];
[coder encodeBool: _incrementalSearchingEnabled
forKey: @"NSIncrementalSearchingEnabled"];
[coder encodeBool: _incrementalSearchingShouldDimContentView
forKey: @"NSIncrementalSearchingShouldDimContentView"];
[coder encodeObject: _incrementalMatchRanges
forKey: @"NSIncrementalMatchRanges"];
}
else
{
[coder encodeValueOfObjCType: @encode(BOOL)
at: &_findIndicatorNeedsUpdate];
[coder encodeValueOfObjCType: @encode(BOOL)
at: &_incrementalSearchingEnabled];
[coder encodeValueOfObjCType: @encode(BOOL)
at: &_incrementalSearchingShouldDimContentView];
[coder encodeObject: _incrementalMatchRanges];
}
}
@end

110
Source/NSTextInputContext.m Normal file
View file

@ -0,0 +1,110 @@
/* Implementation of class NSTextInputContext
Copyright (C) 2020 Free Software Foundation, Inc.
By: Gregory John Casamento
Date: 02-08-2020
This file is part of the GNUstep Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110 USA.
*/
#import <Foundation/NSArray.h>
#import <Foundation/NSString.h>
#import "AppKit/NSTextInputContext.h"
NSTextInputContext *__currentInputContext;
@implementation NSTextInputContext
+ (NSTextInputContext *) currentInputContext
{
return __currentInputContext;
}
- (instancetype) initWithClient: (id<NSTextInputClient>)client
{
self = [super init];
if (self != nil)
{
_client = client;
}
return self;
}
- (id<NSTextInputClient>) client
{
return _client;
}
- (BOOL) acceptsGlyphInfo
{
return _acceptsGlyphInfo;
}
- (void) setAcceptsGlyphInfo: (BOOL)flag
{
_acceptsGlyphInfo = flag;
}
- (NSArray *) allowedInputSourceLocales
{
return _allowedInputSourceLocales;
}
- (void) setAllowedInputSourceLocales: (NSArray *)locales
{
ASSIGNCOPY(_allowedInputSourceLocales, locales);
}
- (void) activate
{
}
- (void) deactivate
{
}
- (BOOL) handleEvent: (NSEvent *)event
{
return YES;
}
- (void) discardMarkedText
{
}
- (void) invalidateCharacterCoordinates
{
}
- (NSArray *) keyboardInputSources
{
return _keyboardInputSources;
}
- (NSTextInputSourceIdentifier) selectedKeyboardInputSource
{
return _selectedKeyboardInputSource;
}
+ (NSString *) localizedNameForInputSource:(NSTextInputSourceIdentifier)inputSourceIdentifier
{
return nil;
}
@end

View file

@ -1,6 +1,6 @@
/** <title>NSTextView</title>
Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2008 Free Software Foundation, Inc.
Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2008, 2020 Free Software Foundation, Inc.
Much code of this class was originally derived from code which was
in NSText.m.
@ -26,6 +26,9 @@
Extensive reworking: Alexander Malmberg <alexander@malmberg.org>
Date: December 2002 - February 2003
Implementing Catalina Extensions: Gregory Casamento <greg.casamento@gmail.com>
Date: August 2020
This file is part of the GNUstep GUI Library.
This library is free software; you can redistribute it and/or
@ -61,6 +64,7 @@
#import <Foundation/NSTimer.h>
#import <Foundation/NSUndoManager.h>
#import <Foundation/NSValue.h>
#import "AppKit/NSApplication.h"
#import "AppKit/NSAttributedString.h"
#import "AppKit/NSClipView.h"
@ -89,6 +93,7 @@
#import "AppKit/NSTextStorage.h"
#import "AppKit/NSTextView.h"
#import "AppKit/NSWindow.h"
#import "GSGuiPrivate.h"
#import "GSTextFinder.h"
#import "GSToolTips.h"
@ -4016,12 +4021,8 @@ Figure out how the additional layout stuff is supposed to work.
* were! */
[self drawViewBackgroundInRect: [self bounds]];
/* Then draw the special background of the new glyphs. */
[_layoutManager drawBackgroundForGlyphRange: drawnRange
atPoint: _textContainerOrigin];
[_layoutManager drawGlyphsForGlyphRange: drawnRange
atPoint: _textContainerOrigin];
[self drawCharactersInRange: drawnRange
forContentView: self];
if ([self shouldDrawInsertionPoint] &&
[NSGraphicsContext currentContextDrawingToScreen])
@ -6078,6 +6079,113 @@ configuation! */
withTextView: self];
}
// NSTextFinder methods implementation...
// isSelectable, isEditable, string, selectedRanges, setSelectedRanges, replaceCharactersInRange:withString:
// implemented by NSTextView already...
- (BOOL) allowsMultipleSelection
{
return NO;
}
- (NSString *) stringAtIndex: (NSUInteger)characterIndex
effectiveRange: (NSRangePointer)outRange
endsWithSearchBoundary: (BOOL *)outFlag
{
return [self string];
}
- (NSUInteger) stringLength
{
return [[self string] length];
}
- (NSRange) firstSelectedRange
{
NSValue *r = [[self selectedRanges] objectAtIndex: 0];
return [r rangeValue];
}
- (BOOL) shouldReplaceCharactersInRanges: (NSArray *)ranges withStrings: (NSArray *)strings
{
NSUInteger idx = 0;
FOR_IN(NSValue*, rv, ranges)
{
NSRange r = [rv rangeValue];
NSString *str = [strings objectAtIndex: idx];
if (![self shouldChangeTextInRange: r replacementString: str])
{
return NO;
}
idx++;
}
END_FOR_IN(ranges);
return YES;
}
- (void) didReplaceCharacters
{
[self didChangeText];
}
- (NSView *) contentViewAtIndex: (NSUInteger)index effectiveCharacterRange: (NSRangePointer)outRange
{
return nil;
}
- (NSArray *) rectsForCharacterRange: (NSRange)range
{
NSUInteger rectCount = 0;
NSRect *rects;
NSMutableArray *result = [NSMutableArray array];
NSUInteger idx = 0;
rects = [_layoutManager rectArrayForCharacterRange: range
withinSelectedCharacterRange: NSMakeRange(NSNotFound, 0)
inTextContainer: _textContainer
rectCount: &rectCount];
for (idx = 0; idx < rectCount; idx++)
{
NSRect r = rects[idx];
NSValue *v = [NSValue valueWithRect: r];
[result addObject: v];
}
return result;
}
- (NSArray *) visibleCharacterRanges
{
NSArray *result = nil;
if (_layoutManager)
{
const NSRect visibleRect = [self visibleRect];
NSRange visibleGlyphRange = [_layoutManager glyphRangeForBoundingRect: visibleRect
inTextContainer: _textContainer];
NSRange visibleRange = [_layoutManager characterRangeForGlyphRange: visibleGlyphRange
actualGlyphRange: NULL];
NSValue *value = [NSValue valueWithRange: visibleRange];
result = [NSArray arrayWithObject: value];
}
return result;
}
- (void) drawCharactersInRange: (NSRange)range forContentView: (NSView *)view
{
/* Then draw the special background of the new glyphs. */
[_layoutManager drawBackgroundForGlyphRange: range
atPoint: _textContainerOrigin];
[_layoutManager drawGlyphsForGlyphRange: range
atPoint: _textContainerOrigin];
}
@end

View file

@ -35,6 +35,7 @@
#import "AppKit/NSEvent.h"
#import "AppKit/NSAppearance.h"
#import "AppKit/NSFontCollection.h"
#import "AppKit/NSTextFinder.h"
// Global strings
NSString *NSModalPanelRunLoopMode = @"NSModalPanelRunLoopMode";
@ -834,6 +835,13 @@ NSFontCollectionMatchingOptionKey const NSFontCollectionDisallowAutoActivationOp
// Speech recognition...
const NSString *GSSpeechRecognizerDidRecognizeWordNotification = @"GSSpeechRecognizerDidRecognizeWordNotification";
// NSTextInputContext notifications
NSString *NSTextInputContextKeyboardSelectionDidChangeNotification =
@"NSTextInputContextKeyboardSelectionDidChangeNotification";
NSPasteboardTypeTextFinderOptionKey const NSTextFinderCaseInsensitiveKey = @"NSTextFinderCaseInsensitiveKey";
NSPasteboardTypeTextFinderOptionKey const NSTextFinderMatchingTypeKey = @"NSTextFinderMatchingTypeKey";
extern void __objc_gui_force_linking (void);
void