mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 03:00:37 +00:00
Add encoding.
This commit is contained in:
parent
6bfdb64ef4
commit
8c36246dca
4 changed files with 62 additions and 13 deletions
|
@ -69,6 +69,7 @@ enum
|
|||
typedef NSInteger NSTextFinderMatchingType;
|
||||
|
||||
typedef NSString* NSPasteboardTypeTextFinderOptionKey;
|
||||
|
||||
APPKIT_EXPORT NSPasteboardTypeTextFinderOptionKey const NSTextFinderCaseInsensitiveKey;
|
||||
APPKIT_EXPORT NSPasteboardTypeTextFinderOptionKey const NSTextFinderMatchingTypeKey;
|
||||
|
||||
|
@ -76,7 +77,11 @@ APPKIT_EXPORT NSPasteboardTypeTextFinderOptionKey const NSTextFinderMatchingType
|
|||
{
|
||||
IBOutlet id<NSTextFinderClient> _client;
|
||||
IBOutlet id<NSTextFinderBarContainer> _findBarContainer;
|
||||
|
||||
BOOL _findIndicatorNeedsUpdate;
|
||||
BOOL _incrementalSearchingEnabled;
|
||||
BOOL _incrementalSearchingShouldDimContentView;
|
||||
NSArray *_incrementalMatchRanges;
|
||||
}
|
||||
|
||||
// Validating and performing
|
||||
|
@ -89,7 +94,7 @@ APPKIT_EXPORT NSPasteboardTypeTextFinderOptionKey const NSTextFinderMatchingType
|
|||
- (void) setClient: (id<NSTextFinderClient>) client;
|
||||
- (id<NSTextFinderBarContainer>) findBarContainer;
|
||||
- (void) setFindBarContainer: (id<NSTextFinderBarContainer>) findBarContainer;
|
||||
- (BOOL) findIndicatodNeedsUpdate;
|
||||
- (BOOL) findIndicatorNeedsUpdate;
|
||||
- (void) setFindIndicatorNeedsUpdate: (BOOL)flag;
|
||||
- (BOOL) isIncrementalSearchingEnabled;
|
||||
- (void) setIncrementalSearchingEnabled: (BOOL)flag;
|
||||
|
@ -112,17 +117,12 @@ APPKIT_EXPORT NSPasteboardTypeTextFinderOptionKey const NSTextFinderMatchingType
|
|||
- (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;
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#define _GS_TEXT_FINDER_H
|
||||
|
||||
#import <Foundation/NSObject.h>
|
||||
#import "AppKit/NSTextFinder.h"
|
||||
|
||||
@class NSString;
|
||||
@class NSButton;
|
||||
|
@ -38,7 +39,7 @@
|
|||
@class NSPanel;
|
||||
@class NSTextField;
|
||||
|
||||
@interface GSTextFinder : NSObject
|
||||
@interface GSTextFinder : NSTextFinder
|
||||
{
|
||||
// local attributes
|
||||
NSString *findString;
|
||||
|
|
|
@ -23,10 +23,12 @@
|
|||
*/
|
||||
|
||||
#import <Foundation/NSArray.h>
|
||||
#import <Foundation/NSArchiver.h>
|
||||
|
||||
#import "AppKit/NSTextFinder.h"
|
||||
|
||||
@implementation NSTextFinder
|
||||
|
||||
// Validating and performing
|
||||
- (void)performAction:(NSTextFinderAction)op
|
||||
{
|
||||
|
@ -60,36 +62,39 @@
|
|||
{
|
||||
}
|
||||
|
||||
- (BOOL) findIndicatodNeedsUpdate
|
||||
- (BOOL) findIndicatorNeedsUpdate
|
||||
{
|
||||
return NO;
|
||||
return _findIndicatorNeedsUpdate;
|
||||
}
|
||||
|
||||
- (void) setFindIndicatorNeedsUpdate: (BOOL)flag
|
||||
{
|
||||
_findIndicatorNeedsUpdate = flag;
|
||||
}
|
||||
|
||||
- (BOOL) isIncrementalSearchingEnabled
|
||||
{
|
||||
return NO;
|
||||
return _incrementalSearchingEnabled;
|
||||
}
|
||||
|
||||
- (void) setIncrementalSearchingEnabled: (BOOL)flag
|
||||
{
|
||||
_incrementalSearchingEnabled = flag;
|
||||
}
|
||||
|
||||
- (BOOL) incrementalSearchingShouldDimContentView
|
||||
{
|
||||
return NO;
|
||||
return _incrementalSearchingShouldDimContentView;
|
||||
}
|
||||
|
||||
- (void) setIncrementalSearchingShouldDimContentView: (BOOL)flag
|
||||
{
|
||||
_incrementalSearchingShouldDimContentView = flag;
|
||||
}
|
||||
|
||||
- (NSArray *) incrementalMatchRanges
|
||||
{
|
||||
return nil;
|
||||
return _incrementalMatchRanges;
|
||||
}
|
||||
|
||||
+ (void) drawIncrementalMatchHighlightInRect: (NSRect)rect
|
||||
|
@ -98,12 +103,46 @@
|
|||
|
||||
- (void) noteClientStringWillChange
|
||||
{
|
||||
// nothing...
|
||||
}
|
||||
|
||||
// NSCoding...
|
||||
- (instancetype) initWithCoder: (NSCoder *)coder
|
||||
{
|
||||
return [super init];
|
||||
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"]);
|
||||
}
|
||||
}
|
||||
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
|
||||
|
|
|
@ -6158,6 +6158,15 @@ configuation! */
|
|||
|
||||
- (void) drawCharactersInRange: (NSRange)range forContentView: (NSView *)view
|
||||
{
|
||||
NSArray *rectsArray = [self rectsForCharacterRange: range];
|
||||
NSAttributedString *charactersInRange = [[self string] substringWithRange: range];
|
||||
NSValue *v = [rectsArray objectAtIndex: 0];
|
||||
NSRect rect = [v rectValue];
|
||||
|
||||
[charactersInRange drawWithRect: rect
|
||||
options: 0
|
||||
attributes: nil
|
||||
context: nil];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue