Back to index

lightning-sunbird  0.9+nobinonly
Classes | Functions | Variables
keysym2ucs.c File Reference
#include "keysym2ucs.h"

Go to the source code of this file.

Classes

struct  codepair

Functions

long keysym2ucs (KeySym keysym)

Variables

struct codepair keysymtab []

Class Documentation

struct codepair

Definition at line 74 of file keysym2ucs.c.

Class Members
unsigned short keysym
unsigned short ucs

Function Documentation

long keysym2ucs ( KeySym  keysym)

Definition at line 869 of file keysym2ucs.c.

{
    int min = 0;
    int max = sizeof(keysymtab) / sizeof(struct codepair) - 1;
    int mid;

    /* first check for Latin-1 characters (1:1 mapping) */
    if ((keysym >= 0x0020 && keysym <= 0x007e) ||
        (keysym >= 0x00a0 && keysym <= 0x00ff))
        return keysym;

    /* also check for directly encoded 24-bit UCS characters */
    if ((keysym & 0xff000000) == 0x01000000)
        return keysym & 0x00ffffff;

    /* binary search in table */
    while (max >= min) {
        mid = (min + max) / 2;
        if (keysymtab[mid].keysym < keysym)
            min = mid + 1;
        else if (keysymtab[mid].keysym > keysym)
            max = mid - 1;
        else {
            /* found it */
            return keysymtab[mid].ucs;
        }
    }

    /* no matching Unicode value found */
    return -1;
}

Variable Documentation

struct codepair keysymtab[]