This is MORegexTextCell.h in view mode; [Download] [Up]
// MORegexTextCell.h
//
// by Mike Ferris
// Part of MOKit
// Copyright 1993, all rights reserved.
// ABOUT MOKit
// by Mike Ferris (mike@lorax.com)
//
// MOKit is a collection of useful and general objects. Permission is
// granted by the author to use MOKit in your own programs in any way
// you see fit. All other rights pertaining to the kit are reserved by the
// author including the right to sell these objects as objects, as part
// of a LIBRARY, or as SOURCE CODE. In plain English, I wish to retain
// rights to these objects as objects, but allow the use of the objects
// as pieces in a fully functional program. Permission is also granted to
// redistribute the source code of MOKit for FREE as long as this copyright
// notice is left intact and unchanged. NO WARRANTY is expressed or implied.
// The author will under no circumstances be held responsible for ANY
// consequences from the use of these objects. Since you don't have to pay
// for them, and full source is provided, I think this is perfectly fair.
// ABOUT MORegexFormCell
//
// MORegexTextCell adds entry checking by regular
// expression to TextFieldCell. The cell keeps a list of regular
// expression pattern strings. Ending editing in the cell
// causes the entry to be checked sequentially against the
// cell's patterns. If a match is found the entry is accepted
// and editing ends. If a match is not found with any of the
// patterns, the entry is not accepted and the attempt to end
// editing is aborted. The cell beeps and reselects the text
// remaining the first responder.
//
// The regular expression routines are (verbatim) those of
// Henry Spencer. See the source code and README file in the HSRegex
// directory for information on those routines.
//
// A call to endEditing explicitly may force the editing to
// end. Use this snippet instead (taken from the Window
// class documentation):
//
// if ([myWindow makeFirstResponder:myWindow]) {
// [myWindow endEditingFor:nil];
// . . .
// }
//
// This should allow the form to keep editing if the format is
// incorrect.
//
// The cell's entry is checked by the method -
// (BOOL)isEntryAcceptable:(const char *)aString.
// Whenever this method is called, if it finds a match, it
// does a little extra work. It remembers the substrings of
// aString which matched the subexpressions of the pattern
// that it matched. The cell can be queried for any of these
// substrings. The method -(const char *)pieceAt:(int)index
// gives back a pointer to the substring that matched
// subexpression index in the pattern that was last matched.
// Piece number zero is the substring that matched the
// entire pattern (this may not be the whole contents of the cell).
#import <appkit/appkit.h>
@interface MORegexTextCell:TextFieldCell
{
List *regexStrs;
BOOL allowEmptyString;
int pieceCount;
char *pieces[10];
int matchedIndex;
id delegate;
}
+ initialize;
+ (BOOL)isValidRegex:(const char *)str;
- initTextCell:(const char *)aString;
- initTextCell:(const char *)aString withRegex:(const char *)re;
- copyFromZone:(NXZone *)zone;
- free;
- (BOOL)isEntryAcceptable:(const char *)aString;
- (const char *)regexStr;
- setRegexStr:(const char *)re;
- (const char *)regexStrAt:(int)index;
- addRegexStr:(const char *)re;
- removeRegexStrAt:(int)index;
- (int)regexStrCount;
- regexStrList;
- (int)pieceCount;
- (const char *)pieceAt:(int)n;
- (int)matchedPatternIndex;
- (BOOL)doesAllowEmptyString;
- setAllowEmptyString:(BOOL)flag;
- delegate;
- setDelegate:obj;
- setDoubleValue:(double)aDouble;
- setFloatValue:(float)aFloat;
- setIntValue:(int)anInt;
- setStringValue:(const char *)aString;
- setStringValueNoCopy:(const char *)aString;
- setStringValueNoCopy:(char *)aString shouldFree:(BOOL)flag;
- awake;
- read:(NXTypedStream *)strm;
- write:(NXTypedStream *)strm;
- (const char *)getInspectorClassName;
@end
@interface Object(MORegexTextCellDelegate)
// The delegate gets this message after the string has passed the regular
// expression validation. If the string is checked for accuracy and fails
// the form cell's regular expression tests, the delegate won't get this
// message. The delegate can return YES to allow the string or NO to
// reject it.
- (BOOL)finishValidating:(const char *)aString for:sender;
@end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.