ftp.nice.ch/pub/next/developer/resources/classes/XText.0.9.beta3.s.tar.gz#/XText0.9/XText.subproj/XTAction.h

This is XTAction.h in view mode; [Download] [Up]

#import <objc/Object.h>
#import <dpsclient/event.h>

/*	An XTAction specifies the action to be taken in response to a key event.
	When a key event occurs, the applyTo:event: method is invoked; this is
	the key method that must be implemented by the subclasses of XTAction.

	Actions normally return self from the applyTo:event: method, but by
	returning nil they can cause the event to be handled normally by XText0's
	superclass (i.e. Text).

	The class method undefinedAction returns a default action that invokes
	the text object's unboundKey method.
*/

@interface XTAction:Object
{
}
+ undefinedAction;
- applyTo:xtext event:(NXEvent *)event;
@end

#define MAPPED_KEYS      256			//	table size for a dispatch action
#define NUM_MASKS        7  			// keyboard independent flags
/* 
NX_ALPHASHIFTMASK Shift lock
NX_SHIFTMASK      Shift key
NX_CONTROLMASK	  Control key 
NX_ALTERNATEMASK  Alt key
NX_COMMANDMASK	  Command key 
NX_NUMERICPADMASK Number pad key
NX_HELPMASK	      Help key

 charCodes are 128 * event->data.key.charCode,
		+ 1 if shift lock,
		+ 2 if shift,
		+ 4 if control,
		+ 8 if alt
		+ 16 if command
		+ 32 if numeric keypad
		+ 64 if help key
*/

#define CHAR_CODES  (MAPPED_KEYS * (1 << NUM_MASKS) )//combinations/key

typedef int charCode;
typedef XTAction *actionTbl[CHAR_CODES];

/*	XTMsg0Action, XTMsg1Action, and XTMsg2Action are subclasses of XTAction
	that send a specified message to the text object with 0, 1, or 2 args.
*/

@interface XTMsg0Action:XTAction
{
	SEL	action_sel;
}
- initSel:(SEL)sel;
@end

@interface XTMsg1Action:XTAction
{
	SEL	action_sel;
	int action_arg;
}
- initSel:(SEL)sel arg:(int)arg;
@end

@interface XTMsg2Action:XTAction
{
	SEL	action_sel;
	int action_arg1;
	int action_arg2;
}
- initSel:(SEL)sel arg:(int)arg1 arg:(int)arg2;
@end

/*	XTDispatchAction is a subclass of XTAction that maintains a dispatch
	table of other actions and selects one based on the key pressed.  The
	methods are
		init				initializes all actions to `nil'.  XText
							has default NeXT Text Class behavior 

		initBase:estream:	the first argument is a string naming a 'base'
							set of initial bindings; the only values currently
							supported are "none". 

		loadFromFile:fullName estream:errs
							loads keybindings from a file.  Comments are
							lines in the file beginning with `#'.  This 
							method enables developers to load keybinding
							files from their .app wrapper directories.

		bindKey:toAction:estream:
							bind a key to a specified action; an action of nil
							will cause the key to be handled normally by the
							Text class

		addBindings:estream:
							parse and install the bindings specified by a
							string

	The estream argument is used to report any errors; if it is nil, the
	default error stream (which simply pops up an alert panel) is used.
*/

@interface XTDispatchAction:XTAction
{
	actionTbl actions;
}
- init;
- initBase:(const char *)base estream:errs;
- loadFromFile:(char *)fullName estream:errs;
- bindKey:(charCode)key toAction:action estream:errs;
@end

@interface XTDispatchAction(parsing)
- addBindings:(const char *)bindings estream:errs;
@end

/*	XTEventMsgAction is a subclass of XTAction that sends a specified
	message to the text object, passing the event as an argument.
	This is useful for implementing some special-purpose prefix commands
	like 'quote next character'
*/

@interface XTEventMsgAction:XTAction
{
	SEL action_sel;
}
- initSel:(SEL)sel;
@end

/*	XTSeqAction is a subclass of XTAction that invokes a sequence of
	subactions.
*/

@interface XTSeqAction:XTAction
{
	int length;
	XTAction **actions;
}
- initLength:(int)len actions:(XTAction **)acts;
@end

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.