From c647d540a702890e8b182b1640fdfa1bd94ced82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Mon, 27 Feb 2023 21:55:39 +0100 Subject: core: remove obsolete function gui_key_legacy_expand --- src/gui/gui-key.c | 59 ----------------------------------------- src/gui/gui-key.h | 1 - tests/unit/gui/test-gui-key.cpp | 28 ------------------- 3 files changed, 88 deletions(-) diff --git a/src/gui/gui-key.c b/src/gui/gui-key.c index 6b121912b..60af69e08 100644 --- a/src/gui/gui-key.c +++ b/src/gui/gui-key.c @@ -375,65 +375,6 @@ gui_key_legacy_internal_code (const char *key) return string_dyn_free (result, 0); } -/* - * Gets expanded name from internal key code (legacy function). - * - * Examples: - * "\001j" => "ctrl-j" - * "\001m" => "ctrl-m" - * "\001r" => "ctrl-r" - * "\001[A" => "meta-A" - * "\001[a" => "meta-a" - * "\001[[1;3D" => "meta2-1;3D" - * "\001[w\001[[1;3A" => "meta-wmeta2-1;3A" - * - * Note: result must be freed after use. - */ - -char * -gui_key_legacy_expand (const char *key) -{ - char **result; - - if (!key) - return NULL; - - result = string_dyn_alloc ((strlen (key) * 2) + 1); - if (!result) - return NULL; - - while (key[0]) - { - if (strncmp (key, "\x01[[", 3) == 0) - { - string_dyn_concat (result, "meta2-", -1); - key += 3; - } - if (strncmp (key, "\x01[", 2) == 0) - { - string_dyn_concat (result, "meta-", -1); - key += 2; - } - else if ((key[0] == '\x01') && (key[1])) - { - string_dyn_concat (result, "ctrl-", -1); - key++; - } - else if (key[0] == ' ') - { - string_dyn_concat (result, "space", -1); - key++; - } - else - { - string_dyn_concat (result, key, 1); - key++; - } - } - - return string_dyn_free (result, 0); -} - /* * Expands raw key code to its name and name using aliases (human readable * key name). diff --git a/src/gui/gui-key.h b/src/gui/gui-key.h index c28658761..fed8ca750 100644 --- a/src/gui/gui-key.h +++ b/src/gui/gui-key.h @@ -92,7 +92,6 @@ extern void gui_key_init (); extern int gui_key_search_context (const char *context); extern void gui_key_grab_init (int grab_raw_key, int grab_command, const char *delay); -extern char *gui_key_legacy_expand (const char *key); extern int gui_key_expand (const char *key, char **key_name, char **key_name_alias); extern char *gui_key_legacy_to_alias (const char *key); diff --git a/tests/unit/gui/test-gui-key.cpp b/tests/unit/gui/test-gui-key.cpp index 31f6494f3..b99799cd1 100644 --- a/tests/unit/gui/test-gui-key.cpp +++ b/tests/unit/gui/test-gui-key.cpp @@ -146,34 +146,6 @@ TEST(GuiKey, LegacyInternalCode) WEE_TEST_STR(" ", gui_key_legacy_internal_code ("space")); } -/* - * Tests functions: - * gui_key_legacy_expand - */ - -TEST(GuiKey, ExpandLegacy) -{ - char *str; - - WEE_TEST_STR(NULL, gui_key_legacy_expand (NULL)); - WEE_TEST_STR("", gui_key_legacy_expand ("")); - WEE_TEST_STR("A", gui_key_legacy_expand ("A")); - WEE_TEST_STR("a", gui_key_legacy_expand ("a")); - - WEE_TEST_STR("@chat:t", gui_key_legacy_expand ("@chat:t")); - - WEE_TEST_STR("meta-A", gui_key_legacy_expand ("\001[A")); - WEE_TEST_STR("meta-a", gui_key_legacy_expand ("\001[a")); - - WEE_TEST_STR("meta2-A", gui_key_legacy_expand ("\001[[A")); - WEE_TEST_STR("meta2-a", gui_key_legacy_expand ("\001[[a")); - - WEE_TEST_STR("ctrl-A", gui_key_legacy_expand ("\001A")); - WEE_TEST_STR("ctrl-a", gui_key_legacy_expand ("\001a")); - - WEE_TEST_STR("space", gui_key_legacy_expand (" ")); -} - /* * Tests functions: * gui_key_expand -- cgit v1.2.3