File indexing completed on 2024-11-24 05:00:21

0001 /*
0002     GDK - The GIMP Drawing Kit
0003     SPDX-FileCopyrightText: 1995-1997 Peter Mattis
0004     SPDX-FileCopyrightText: 1995-1997 Spencer Kimball
0005     SPDX-FileCopyrightText: 1995-1997 Josh MacDonald
0006 
0007     SPDX-License-Identifier: LGPL-2.0-or-later
0008 */
0009 
0010 /*
0011  * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
0012  * file for a list of people on the GTK+ Team.  See the ChangeLog
0013  * files for a list of changes.  These files are distributed with
0014  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
0015  */
0016 
0017 #include <glib.h>
0018 #include "gdkkeynames_p.h"
0019 #include "gdkkeysyms_p.h"
0020 
0021 /* Key handling not part of the keymap */
0022 
0023 #include "keyname-table.h"
0024 
0025 #include <glib/gprintf.h>
0026 #include <stdlib.h>
0027 #include <string.h>
0028 
0029 #define GDK_NUM_KEYS G_N_ELEMENTS (gdk_keys_by_keyval)
0030 
0031 static int
0032 _gdk_keys_name_compare (const void *pkey, const void *pbase)
0033 {
0034   return strcmp ((const char *) pkey, 
0035          (const char *) (keynames + ((const gdk_key *) pbase)->offset));
0036 }
0037 
0038 guint
0039 _gdk_keyval_from_name (const gchar *keyval_name)
0040 {
0041   gdk_key *found;
0042 
0043   g_return_val_if_fail (keyval_name != NULL, 0);
0044   
0045   found = bsearch (keyval_name, gdk_keys_by_name,
0046            GDK_NUM_KEYS, sizeof (gdk_key),
0047            _gdk_keys_name_compare);
0048   if (found != NULL)
0049     return found->keyval;
0050   else
0051     return GDK_KEY_VoidSymbol;
0052 }