XLookupString()XLookupString()NameXLookupString – map a key event to ASCII string, keysym, and ComposeS‐
tatus.
Synopsis
int XLookupString(event_structure, buffer_return, bytes_buffer,
keysym_return,
status_in_out)
XKeyEvent *event_structure;
char *buffer_return;
int bytes_buffer;
KeySym *keysym_return;
XComposeStatus *status_in_out; /* may not be implemented
*/
Arguments
event_structure
Specifies the key event to be used.
buffer_return
Returns the resulting string (not NULL-terminated). Returned
value of the function is the length of the string.
bytes_buffer
Specifies the length of the buffer. No more than bytes_buf‐
fer of translation are returned.
keysym_return
If this argument is not NULL, it specifies the keysym ID com‐
puted from the event.
status_in_out
Specifies the XComposeStatus structure that contains compose
key state information and that allows the compose key pro‐
cessing to take place. This can be NULL if the caller is not
interested in seeing compose key sequences. Not implemented
in X Consortium Xlib through Release 5.
Returns
Length of string in buffer_return argument.
DescriptionXLookupString() gets an ASCII string and a keysym that are currently
mapped to the keycode in a KeyPress or KeyRelease event, using the mod‐
ifier bits in the key event to deal with shift, lock and control. The
XLookupString() return value is the length of the translated string and
the string's bytes are copied into buffer_return. The length may be
greater than 1 if the event's keycode translates into a keysym that was
rebound with XRebindKeysym().
Note that the string returned in buffer is not NULL-terminated. If you
need a NULL-terminated string, copy buffer into another string as fol‐
lows:
len = XLookupString((XKeyEvent *)event, buffer, 10, nil, nil);
if (len)
(void) strncat (cmd_buf, buffer, len);
The compose status.in.out is not implemented in any release of the X
Consortium version of Xlib through Release 5.
In Release 4, XLookupString() implements the new concept of keyboard
groups. Keyboard groups support having two complete sets of keysyms
for a keyboard. Which set will be used can be toggled using a particu‐
lar key. This is implemented by using the first two keysyms in the
list for a key as one set, and the next two keysyms as the second set.
For more information on keyboard groups, see Volume One, Appendix G,
Release Notes.
For more information on using XLookupString() in general, see Volume
One, Chapter 9, The Keyboard and Pointer.
Structures
/*
* Compose sequence status.in.out structure, used in calling XLookupString.
*/
typedef struct _XComposeStatus {
char *compose_ptr; /* state table pointer */
int chars_matched; /* match state */
} XComposeStatus;
typedef struct {
int type; /* of event */
unsigned long serial; /* # of last request processed by server */
Bool send_event; /* true if this came from a SendEvent request */
Display *display; /* Display the event was read from */
Window window; /* "event" window it is reported relative to */
Window root; /* root window that the event occured on */
Window subwindow; /* child window */
Time time; /* milliseconds */
int x, y; /* pointer x, y coordinates in event window */
int x_root, y_root; /* coordinates relative to root */
unsigned int state; /* key or button mask */
unsigned int keycode; /* detail */
Bool same_screen; /* same screen flag */
} XKeyEvent;
See AlsoXChangeKeyboardMapping(), XDeleteModifiermapEntry(), XFreeModi‐
fiermap(), XGetKeyboardMapping(), XGetModifierMapping(), XInsertModi‐
fiermapEntry(), XKeycodeToKeysym(), XKeysymToKeycode(), XKeysym‐
ToString(), XLookupKeysym(), XNewModifiermap(), XQueryKeymap(), XRe‐
bindKeysym(), XRefreshKeyboardMapping(), XSetModifierMapping(),
XStringToKeysym().
Xlib - Keyboard XLookupString()