⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xkeysymstr.c

📁 早期freebsd实现
💻 C
字号:
/* $XConsortium: XKeysymStr.c,v 11.7 91/05/04 14:03:22 rws Exp $ *//* Copyright 1990 Massachusetts Institute of Technology *//*Permission to use, copy, modify, distribute, and sell this software and itsdocumentation for any purpose is hereby granted without fee, provided thatthe above copyright notice appear in all copies and that both thatcopyright notice and this permission notice appear in supportingdocumentation, and that the name of M.I.T. not be used in advertising orpublicity pertaining to distribution of the software without specific,written prior permission.  M.I.T. makes no representations about thesuitability of this software for any purpose.  It is provided "as is"without express or implied warranty.*/#include "Xlibint.h"#include <X11/Xresource.h>#include <X11/keysymdef.h>#if __STDC__#define Const const#else#define Const /**/#endiftypedef unsigned long Signature;#define NEEDVTABLE#include "ks_tables.h"extern XrmDatabase _XInitKeysymDB();extern Const unsigned char _XkeyTable[];typedef struct _GRNData {    char *name;    XrmRepresentation type;    XrmValuePtr value;} GRNData;/*ARGSUSED*/static Bool SameValue(db, bindings, quarks, type, value, data)    XrmDatabase		*db;    XrmBindingList      bindings;    XrmQuarkList	quarks;    XrmRepresentation   *type;    XrmValuePtr		value;    XPointer		data;{    GRNData *gd = (GRNData *)data;    if ((*type == gd->type) && (value->size == gd->value->size) &&	!strncmp((char *)value->addr, (char *)gd->value->addr, value->size))    {	gd->name = XrmQuarkToString(*quarks); /* XXX */	return True;    }    return False;}char *XKeysymToString(ks)    KeySym ks;{    register int i, n;    int h;    register int idx;    Const unsigned char *entry;    unsigned char val1, val2;    XrmDatabase keysymdb;    if (!ks)	return ((char *)NULL);    if (ks == XK_VoidSymbol)	ks = 0;    if (ks <= 0xffff)    {	val1 = ks >> 8;	val2 = ks & 0xff;	i = ks % VTABLESIZE;	h = i + 1;	n = VMAXHASH;	while (idx = hashKeysym[i])	{	    entry = &_XkeyTable[idx];	    if ((entry[0] == val1) && (entry[1] == val2))		return ((char *)entry + 2);	    if (!--n)		break;	    i += h;	    if (i >= VTABLESIZE)		i -= VTABLESIZE;	}    }    if (keysymdb = _XInitKeysymDB())    {	char buf[9];	XrmValue resval;	XrmQuark empty = NULLQUARK;	GRNData data;	sprintf(buf, "%lX", ks);	resval.addr = (XPointer)buf;	resval.size = strlen(buf) + 1;	data.name = (char *)NULL;	data.type = XrmPermStringToQuark("String");	data.value = &resval;	(void)XrmEnumerateDatabase(keysymdb, &empty, &empty, XrmEnumAllLevels,				   SameValue, (XPointer)&data);	return data.name;    }    return ((char *) NULL);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -