gandi_keyalias(3) - Linux man page

Name

Here you could find some information on key aliases.

Synopsis

#include <gandi_core.h>

int GANDI_get_keyalias(void *w, int k);

int GANDI_rem_keyalias(void *w, int key);

int GANDI_set_keyalias(void *w, int key, int alias);

int GANDI_stencil_keyalias(void *w, const GANDIT_key_alias stencil[], int rule);

Description

GANDI supports aliases, i.e. if the pressed key has an alias, it will be subsituted and the widget will never know the true key, but only the alias. This capability allows one to have different keys with the same effect.

The first argument of all functions is a widget, because each widget has its own set of aliases. They are stored in the key_alias property (see gandi_gandiw(3gandi)) of GANDIT_key_alias **. This simple structure has the following definition:

typedef struct _GANDIT_key_alias {
        int key;   // a key which is to be aliased
        int alias; // its alias
} GANDIT_key_alias;
Thus, if the key KEY_HOME has an alias KEY_END, then GANDI_action_driver (see gandi_driver(3gandi)), when KEY_HOME is pressed, will recieve KEY_END and there is no way to know exactly which key was pressed.

In order to work with key aliases several functions are provided.

int GANDI_get_keyalias(void *w, int k);

Returns an alias of the specified key k and widget w. If the key has no alias, k will be returned.

int GANDI_rem_keyalias(void *w, int key);

Removes alias for the key key. The return value is either OK or ERR. ERR is possible only when GANDI_declist (see gandi_list(3gandi)) failed, in which case the widget's key_alias will be unchanged. Otherwise OK will be returned, even when the key has no alias.

int GANDI_set_keyalias(void *w, int key, int alias);

Aliases key with alias. Function returns ERR if GANDI_inclist (see gandi_list(3gandi)) failed. In all other cases - OK.

int GANDI_stencil_keyalias(void *w, const GANDIT_key_alias stencil[], int rule);

This function reads aliases from the stencil and applies them to the widget w according to the specified rule. The rule may be one of: GANDI_keyalias_SET, GANDI_keyalias_ADD, GANDI_keyalias_REM.

GANDI_keyalias_SET - the widget's alias set will be an exact copy of the stencil.

GANDI_keyalias_ADD - the aliases from the stencil will be added to the widget's ones with GANDI_set_keyalias.

GANDI_keyalias_REM - the aliases from the stencil will be removed from the widget's list with GANDI_rem_keyalias.

Return value is either OK or ERR. The ERR does not mean that the widget's aliases are still unchanged. It means that something is wrong, but the function probably changed some aliases anyhow.

stencil is an array of GANDIT_key_alias and the last element MUST be {0, 0}!

Notes

There is one predefined stencil GANDI_keyalias_vim. It contains some vim's keys (like arrow aliases for 'h', 'j', 'k' and 'l'). You could use it with GANDI_stencil_keyalias.

These routines are not well tested.

See Also

gandi_core(3gandi) gandi_driver(3gandi) gandi_gandiw(3gandi) gandi_list(3gandi)