From 09a124c22697686c8420c5201d25c39d3bd72c13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sun, 20 Jan 2019 01:09:26 +0100 Subject: [PATCH] buflist: add alternate key codes for F1/F2 and alt-F1/alt-F2 (compatibility with terminals) --- ChangeLog.adoc | 1 + src/plugins/buflist/buflist.c | 26 +++++++++++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/ChangeLog.adoc b/ChangeLog.adoc index 74a1bb59a..a88790ae1 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -31,6 +31,7 @@ New features:: Bug fixes:: * core: fix forced highlight on messages sent to other buffers (issue #1277) + * buflist: add alternate key codes for kbd:[F1]/kbd:[F2] and kbd:[Alt+F1]/kbd:[Alt+F2] (compatibility with terminals) * buflist: fix warning displayed when script buffers.pl is loaded (issue #1274) * irc: fix parsing of "time" message tag on FreeBSD (issue #1289) * relay: fix memory leak in connection of client diff --git a/src/plugins/buflist/buflist.c b/src/plugins/buflist/buflist.c index e0b43ef8e..25bf0cfb5 100644 --- a/src/plugins/buflist/buflist.c +++ b/src/plugins/buflist/buflist.c @@ -412,8 +412,19 @@ int weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) { struct t_hashtable *keys; - char str_key[256]; int i; + char str_key[256]; + char *default_keys[][2] = { + { /* */ "meta-OP", "/bar scroll buflist * -100%" }, + { /* */ "meta2-11~", "/bar scroll buflist * -100%" }, + { /* */ "meta-OQ", "/bar scroll buflist * +100%" }, + { /* */ "meta2-12~", "/bar scroll buflist * +100%" }, + { /* m- */ "meta-meta-OP", "/bar scroll buflist * b" }, + { /* m- */ "meta-meta2-11~", "/bar scroll buflist * b" }, + { /* m- */ "meta-meta-OQ", "/bar scroll buflist * e" }, + { /* m- */ "meta-meta2-12~", "/bar scroll buflist * e" }, + { NULL, NULL }, + }; /* make C compiler happy */ (void) argc; @@ -453,14 +464,11 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) if (keys) { /* default keys */ - weechat_hashtable_set (keys, - "meta-OP", "/bar scroll buflist * -100%"); - weechat_hashtable_set (keys, - "meta-OQ", "/bar scroll buflist * +100%"); - weechat_hashtable_set (keys, - "meta-meta-OP", "/bar scroll buflist * b"); - weechat_hashtable_set (keys, - "meta-meta-OQ", "/bar scroll buflist * e"); + for (i = 0; default_keys[i][0]; i++) + { + weechat_hashtable_set (keys, + default_keys[i][0], default_keys[i][1]); + } weechat_key_bind ("default", keys); /* default mouse actions */