#include <parametrized.h>
#include <transform.h>
-MODULE_ID("$Id: tic.c,v 1.225 2016/11/20 00:34:58 tom Exp $")
+MODULE_ID("$Id: tic.c,v 1.230 2016/12/31 12:24:00 tom Exp $")
#define STDIN_NAME "<stdin>"
}
}
+static int
+csi_length(const char *value)
+{
+ int result = 0;
+
+ if (value[0] == '\033' && value[1] == '[') {
+ result = 2;
+ } else if (UChar(value[0]) == 0x9a) {
+ result = 1;
+ }
+ return result;
+}
+
static char
keypad_final(const char *string)
{
{
int j, k;
int want;
- size_t prefix = 0;
size_t suffix;
bool skip[4];
bool repeated = FALSE;
}
if (!repeated) {
char *up = list[1];
+ size_t prefix = (size_t) csi_length(up);
- if (UChar(up[0]) == '\033') {
- if (up[1] == '[') {
- prefix = 2;
- } else {
- prefix = 1;
- }
- } else if (UChar(up[0]) == UChar('\233')) {
- prefix = 1;
- }
if (prefix) {
suffix = prefix;
while (up[suffix] && isdigit(UChar(up[suffix])))
return result;
}
+/*
+ * Check for DEC VT100 private mode for reverse video.
+ */
+static const char *
+skip_DECSCNM(const char *value, int *flag)
+{
+ *flag = -1;
+ if (value != 0) {
+ int skip = csi_length(value);
+ if (skip > 0 &&
+ value[skip++] == '?' &&
+ value[skip++] == '5') {
+ if (value[skip] == 'h') {
+ *flag = 1;
+ } else if (value[skip] == 'l') {
+ *flag = 0;
+ }
+ value += skip + 1;
+ }
+ }
+ return value;
+}
+
static void
check_delays(const char *name, const char *value)
{
const char *p, *q;
- const char *mark = 0;
+ const char *first = 0;
+ const char *last = 0;
for (p = value; *p != '\0'; ++p) {
if (p[0] == '$' && p[1] == '<') {
const char *base = p + 2;
+ const char *mark = 0;
bool maybe = TRUE;
bool mixed = FALSE;
int proportional = 0;
int mandatory = 0;
+ first = p;
+
for (q = base; *q != '\0'; ++q) {
if (*q == '>') {
if (mark == 0)
mixed = TRUE;
}
}
+ last = *q ? (q + 1) : q;
if (*q == '\0') {
maybe = FALSE; /* just an isolated "$<" */
} else if (maybe) {
}
}
}
+
+ if (!strcmp(name, "flash") ||
+ !strcmp(name, "beep")) {
+
+ if (first != 0) {
+ if (first == value || *last == 0) {
+ /*
+ * Delay is on one end or the other.
+ */
+ _nc_warning("expected delay embedded within %s", name);
+ }
+ } else {
+ int flag;
+
+ /*
+ * Check for missing delay when using VT100 reverse-video.
+ * A real VT100 might not need this, but terminal emulators do.
+ */
+ if ((p = skip_DECSCNM(value, &flag)) != 0 &&
+ flag > 0 &&
+ (q = skip_DECSCNM(p, &flag)) != 0 &&
+ flag == 0) {
+ _nc_warning("expected a delay in %s", name);
+ }
+ }
+ }
}
static char *
bool result = FALSE;
if (VALID_STRING(value)) {
- if (value[0] == '\033' && value[1] == '[') {
- result = TRUE;
- value += 2;
- } else if (UChar(value[0]) == 0x9a) {
- result = TRUE;
- value += 1;
- }
- if (result) {
+ int skip = csi_length(value);
+
+ if (skip) {
int ch;
+
+ result = TRUE;
+ value += skip;
while ((ch = UChar(*value++)) != '\0') {
if (isdigit(ch) || ch == ';') {
;