mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 03:40:47 +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 NSInteger NSTextFinderMatchingType;
|
||||||
|
|
||||||
typedef NSString* NSPasteboardTypeTextFinderOptionKey;
|
typedef NSString* NSPasteboardTypeTextFinderOptionKey;
|
||||||
|
|
||||||
APPKIT_EXPORT NSPasteboardTypeTextFinderOptionKey const NSTextFinderCaseInsensitiveKey;
|
APPKIT_EXPORT NSPasteboardTypeTextFinderOptionKey const NSTextFinderCaseInsensitiveKey;
|
||||||
APPKIT_EXPORT NSPasteboardTypeTextFinderOptionKey const NSTextFinderMatchingTypeKey;
|
APPKIT_EXPORT NSPasteboardTypeTextFinderOptionKey const NSTextFinderMatchingTypeKey;
|
||||||
|
|
||||||
|
@ -76,7 +77,11 @@ APPKIT_EXPORT NSPasteboardTypeTextFinderOptionKey const NSTextFinderMatchingType
|
||||||
{
|
{
|
||||||
IBOutlet id<NSTextFinderClient> _client;
|
IBOutlet id<NSTextFinderClient> _client;
|
||||||
IBOutlet id<NSTextFinderBarContainer> _findBarContainer;
|
IBOutlet id<NSTextFinderBarContainer> _findBarContainer;
|
||||||
|
|
||||||
BOOL _findIndicatorNeedsUpdate;
|
BOOL _findIndicatorNeedsUpdate;
|
||||||
|
BOOL _incrementalSearchingEnabled;
|
||||||
|
BOOL _incrementalSearchingShouldDimContentView;
|
||||||
|
NSArray *_incrementalMatchRanges;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validating and performing
|
// Validating and performing
|
||||||
|
@ -89,7 +94,7 @@ APPKIT_EXPORT NSPasteboardTypeTextFinderOptionKey const NSTextFinderMatchingType
|
||||||
- (void) setClient: (id<NSTextFinderClient>) client;
|
- (void) setClient: (id<NSTextFinderClient>) client;
|
||||||
- (id<NSTextFinderBarContainer>) findBarContainer;
|
- (id<NSTextFinderBarContainer>) findBarContainer;
|
||||||
- (void) setFindBarContainer: (id<NSTextFinderBarContainer>) findBarContainer;
|
- (void) setFindBarContainer: (id<NSTextFinderBarContainer>) findBarContainer;
|
||||||
- (BOOL) findIndicatodNeedsUpdate;
|
- (BOOL) findIndicatorNeedsUpdate;
|
||||||
- (void) setFindIndicatorNeedsUpdate: (BOOL)flag;
|
- (void) setFindIndicatorNeedsUpdate: (BOOL)flag;
|
||||||
- (BOOL) isIncrementalSearchingEnabled;
|
- (BOOL) isIncrementalSearchingEnabled;
|
||||||
- (void) setIncrementalSearchingEnabled: (BOOL)flag;
|
- (void) setIncrementalSearchingEnabled: (BOOL)flag;
|
||||||
|
@ -112,17 +117,12 @@ APPKIT_EXPORT NSPasteboardTypeTextFinderOptionKey const NSTextFinderMatchingType
|
||||||
- (BOOL) isSelectable;
|
- (BOOL) isSelectable;
|
||||||
- (BOOL) allowsMultipleSelection;
|
- (BOOL) allowsMultipleSelection;
|
||||||
- (BOOL) isEditable;
|
- (BOOL) isEditable;
|
||||||
|
|
||||||
- (NSString *) string;
|
- (NSString *) string;
|
||||||
|
|
||||||
- (NSString *) stringAtIndex: (NSUInteger)characterIndex
|
- (NSString *) stringAtIndex: (NSUInteger)characterIndex
|
||||||
effectiveRange: (NSRangePointer)outRange
|
effectiveRange: (NSRangePointer)outRange
|
||||||
endsWithSearchBoundary: (BOOL *)outFlag;
|
endsWithSearchBoundary: (BOOL *)outFlag;
|
||||||
|
|
||||||
- (NSUInteger) stringLength;
|
- (NSUInteger) stringLength;
|
||||||
|
|
||||||
- (NSRange) firstSelectedRange;
|
- (NSRange) firstSelectedRange;
|
||||||
|
|
||||||
- (NSArray *) selectedRanges;
|
- (NSArray *) selectedRanges;
|
||||||
- (void) setSelectedRanges: (NSArray *)ranges;
|
- (void) setSelectedRanges: (NSArray *)ranges;
|
||||||
- (void) scrollRangeToVisible:(NSRange)range;
|
- (void) scrollRangeToVisible:(NSRange)range;
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#define _GS_TEXT_FINDER_H
|
#define _GS_TEXT_FINDER_H
|
||||||
|
|
||||||
#import <Foundation/NSObject.h>
|
#import <Foundation/NSObject.h>
|
||||||
|
#import "AppKit/NSTextFinder.h"
|
||||||
|
|
||||||
@class NSString;
|
@class NSString;
|
||||||
@class NSButton;
|
@class NSButton;
|
||||||
|
@ -38,7 +39,7 @@
|
||||||
@class NSPanel;
|
@class NSPanel;
|
||||||
@class NSTextField;
|
@class NSTextField;
|
||||||
|
|
||||||
@interface GSTextFinder : NSObject
|
@interface GSTextFinder : NSTextFinder
|
||||||
{
|
{
|
||||||
// local attributes
|
// local attributes
|
||||||
NSString *findString;
|
NSString *findString;
|
||||||
|
|
|
@ -23,10 +23,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import <Foundation/NSArray.h>
|
#import <Foundation/NSArray.h>
|
||||||
|
#import <Foundation/NSArchiver.h>
|
||||||
|
|
||||||
#import "AppKit/NSTextFinder.h"
|
#import "AppKit/NSTextFinder.h"
|
||||||
|
|
||||||
@implementation NSTextFinder
|
@implementation NSTextFinder
|
||||||
|
|
||||||
// Validating and performing
|
// Validating and performing
|
||||||
- (void)performAction:(NSTextFinderAction)op
|
- (void)performAction:(NSTextFinderAction)op
|
||||||
{
|
{
|
||||||
|
@ -60,36 +62,39 @@
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) findIndicatodNeedsUpdate
|
- (BOOL) findIndicatorNeedsUpdate
|
||||||
{
|
{
|
||||||
return NO;
|
return _findIndicatorNeedsUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setFindIndicatorNeedsUpdate: (BOOL)flag
|
- (void) setFindIndicatorNeedsUpdate: (BOOL)flag
|
||||||
{
|
{
|
||||||
|
_findIndicatorNeedsUpdate = flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) isIncrementalSearchingEnabled
|
- (BOOL) isIncrementalSearchingEnabled
|
||||||
{
|
{
|
||||||
return NO;
|
return _incrementalSearchingEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setIncrementalSearchingEnabled: (BOOL)flag
|
- (void) setIncrementalSearchingEnabled: (BOOL)flag
|
||||||
{
|
{
|
||||||
|
_incrementalSearchingEnabled = flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) incrementalSearchingShouldDimContentView
|
- (BOOL) incrementalSearchingShouldDimContentView
|
||||||
{
|
{
|
||||||
return NO;
|
return _incrementalSearchingShouldDimContentView;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setIncrementalSearchingShouldDimContentView: (BOOL)flag
|
- (void) setIncrementalSearchingShouldDimContentView: (BOOL)flag
|
||||||
{
|
{
|
||||||
|
_incrementalSearchingShouldDimContentView = flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSArray *) incrementalMatchRanges
|
- (NSArray *) incrementalMatchRanges
|
||||||
{
|
{
|
||||||
return nil;
|
return _incrementalMatchRanges;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (void) drawIncrementalMatchHighlightInRect: (NSRect)rect
|
+ (void) drawIncrementalMatchHighlightInRect: (NSRect)rect
|
||||||
|
@ -98,12 +103,46 @@
|
||||||
|
|
||||||
- (void) noteClientStringWillChange
|
- (void) noteClientStringWillChange
|
||||||
{
|
{
|
||||||
|
// nothing...
|
||||||
}
|
}
|
||||||
|
|
||||||
// NSCoding...
|
// NSCoding...
|
||||||
- (instancetype) initWithCoder: (NSCoder *)coder
|
- (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
|
- (void) encodeWithCoder: (NSCoder *)coder
|
||||||
|
|
|
@ -6158,6 +6158,15 @@ configuation! */
|
||||||
|
|
||||||
- (void) drawCharactersInRange: (NSRange)range forContentView: (NSView *)view
|
- (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
|
@end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue