Programming Guide



sm_keyoption

Sets cursor control key options

#include <smkeys.h>
int sm_keyoption(int key, int mode, int newval);

key
The key whose processing you wish to change.

mode
Specifies the type of action to take on key with one of these values:

newval
The new action to assign to key.

Returns

Description

Use sm_keyoption to change at runtime how sm_input processes key, where key is a cursor control key. Default key option values are built into Panther. This function only works with cursor control keys; these include all Panther logical keys except those of type PF, SPF, and APP. Refer to Table 6-1 in Configuration Guide for a list of Panther logical keys.

There are three different possible values for mode: KEY_ROUTING, KEY_GROUP and KEY_XLATE. The newval arguments that are valid for each mode are described below. All of these modes accept a logical key constant for key.

KEY_ROUTING
Allows access to the EXECUTE and RETURN bits of the routing table. Use this mode to disable a key or to explicitly control the action to take when a key is pressed. The following constants can be assigned to newval:

KEY_GROUP
Allows access to the group action bits. Use this mode to control the action of the cursor when it is within a group. The following values can be assigned to newval:

KEY_XLATE
Allows access to the cursor table. Use this mode to assign key the action performed by newval. key can be any cursor control key excluding INS, MNBR, REFR, SFTS, and LP. newval can be any key—logical, function, application, ASCII, and so on.

Example

/* newline_is_xmit: Map the new line key (Return or Enter on
* most keyboards) to XMIT -or- reset it back to NL.
* Invoke from a control string as:
* ^newline_is_xmit X To make NL act as XMIT
* ^newline_is_xmit N To make NL act as NL */
int newline_is_xmit(char *cs_data);
{
while (*cs_data && *cs_data != ' ')
cs_data++;
while (*cs_data == ' ')
cs_data++;
if (*cs_data == 'X')
{
sm_keyoption(NL, KEY_XLATE, XMIT);
}
else
{
sm_keyoption(NL, KEY_XLATE, NL);
}
return(0);
}