aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHarry Jeffery <harry@exec64.co.uk>2019-08-28 16:52:50 +0100
committerHarry Jeffery <harry@exec64.co.uk>2019-08-28 16:52:50 +0100
commit7218c4f9621be819813a43327e22588c4d551061 (patch)
treeebbb1ca7dab102f7cb461b4530911bc782c37772 /src
parent1ae4db158f7e44599d3c4b5c0d890f576aae6fa5 (diff)
downloadimv-7218c4f9621be819813a43327e22588c4d551061.tar.gz
imv: Warn about legacy bind syntax
Diffstat (limited to 'src')
-rw-r--r--src/imv.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/imv.c b/src/imv.c
index acdb39f..4aa167a 100644
--- a/src/imv.c
+++ b/src/imv.c
@@ -1,6 +1,7 @@
#include "imv.h"
#include <assert.h>
+#include <ctype.h>
#include <errno.h>
#include <getopt.h>
#include <stdbool.h>
@@ -237,11 +238,33 @@ static void split_commands(const char *start, const char **out, size_t *len)
*len = str - start;
}
+static bool is_legacy_bind(const char *keys)
+{
+ const char *prefix = "<Shift+";
+ const size_t prefix_len = strlen(prefix);
+ if (strncmp(keys, prefix, prefix_len)) {
+ return false;
+ }
+ /* Has a Shift prefix. Check for single lower case character. */
+ if (islower(keys[prefix_len]) && keys[prefix_len+1] == '>') {
+ return true;
+ }
+
+ return false;
+}
+
static bool add_bind(struct imv *imv, const char *keys, const char *commands)
{
+ if (is_legacy_bind(keys)) {
+ imv_log(IMV_WARNING, "'%s' is the legacy bind syntax.\n"
+ "<Shift+n> would now be <Shift+N>.\n"
+ "Check the imv(5) man page for more syntax examples.\n", keys);
+ return true;
+ }
+
struct list *list = imv_bind_parse_keys(keys);
if (!list) {
- imv_log(IMV_ERROR, "Invalid key combination");
+ imv_log(IMV_ERROR, "Invalid key combination\n");
return false;
}