patch 9.1.1068: getchar() can't distinguish between C-I and Tab
Problem: getchar() can't distinguish between C-I and Tab.
Solution: Add {opts} to pass extra flags to getchar() and getcharstr(),
with "number" and "simplify" keys.
related: #10603
closes: #16554
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/typval.c b/src/typval.c
index e57d898..cd39a0d 100644
--- a/src/typval.c
+++ b/src/typval.c
@@ -527,6 +527,20 @@
}
/*
+ * Give an error and return FAIL unless "args[idx]" is a bool or a number.
+ */
+ int
+check_for_bool_or_number_arg(typval_T *args, int idx)
+{
+ if (args[idx].v_type != VAR_BOOL && args[idx].v_type != VAR_NUMBER)
+ {
+ semsg(_(e_bool_or_number_required_for_argument_nr), idx + 1);
+ return FAIL;
+ }
+ return OK;
+}
+
+/*
* Check for an optional bool argument at 'idx'.
* Return FAIL if the type is wrong.
*/
@@ -539,6 +553,18 @@
}
/*
+ * Check for an optional bool or number argument at 'idx'.
+ * Return FAIL if the type is wrong.
+ */
+ int
+check_for_opt_bool_or_number_arg(typval_T *args, int idx)
+{
+ if (args[idx].v_type == VAR_UNKNOWN)
+ return OK;
+ return check_for_bool_or_number_arg(args, idx);
+}
+
+/*
* Give an error and return FAIL unless "args[idx]" is a blob.
*/
int