Created
October 26, 2013 20:30
-
-
Save alanc/7174179 to your computer and use it in GitHub Desktop.
libxkbfile text program to print XkbKSIsLower() and XkbKSIsUpper() results for ranges of keysyms.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. | |
* | |
* Permission is hereby granted, free of charge, to any person obtaining a | |
* copy of this software and associated documentation files (the "Software"), | |
* to deal in the Software without restriction, including without limitation | |
* the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
* and/or sell copies of the Software, and to permit persons to whom the | |
* Software is furnished to do so, subject to the following conditions: | |
* | |
* The above copyright notice and this permission notice (including the next | |
* paragraph) shall be included in all copies or substantial portions of the | |
* Software. | |
* | |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | |
* DEALINGS IN THE SOFTWARE. | |
*/ | |
/* Compile with cc xkbcasetest.c -o xkbcasetest -lxkbfile */ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <X11/Xlib.h> | |
#include <X11/extensions/XKBstr.h> | |
#include <X11/extensions/XKBfile.h> | |
static const char *ProgramName; | |
static void | |
usage(const char *msg) | |
{ | |
if (msg != NULL) | |
fprintf(stderr, "%s: %s\n", ProgramName, msg); | |
fprintf(stderr, "usage: %s <start>[..<stop>] [...]\n", ProgramName); | |
exit(1); | |
} | |
int | |
main(int argc, char **argv) | |
{ | |
int a; | |
char error[256]; | |
ProgramName = argv[0]; | |
if (argc < 2) | |
usage("No arguments provided"); | |
for (a = 1; a < argc; a++) { | |
KeySym start, stop, ks; | |
char *numend; | |
start = strtol(argv[a], &numend, 0); | |
if (numend != NULL && numend[0] != '\0') { | |
if (numend[0] == '.' && numend[1] == '.') { | |
stop = strtol(&numend[2], NULL, 0); | |
} else { | |
snprintf(error, sizeof(error), "Unable to parse arg %s", | |
argv[a]); | |
usage(error); | |
} | |
} else { | |
stop = start; | |
} | |
for (ks = start; ks <= stop; ks++) { | |
unsigned int casemask = _XkbKSCheckCase(ks); | |
printf("%-32s %08x %5s %5s\n", | |
XkbKeysymText(ks, XkbCFile), ks, | |
(casemask & _XkbKSUpper) ? "upper" : "", | |
(casemask & _XkbKSLower) ? "lower" : ""); | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment