Permalink
Browse files

Switch to 'ansi.sys' terminal type, that seems the lowest common deno…

…mintor.
  • Loading branch information...
bsdphk committed Jan 12, 2018
1 parent 93195a4 commit 945d2e1ea50f52fde10f9b31d55031c58ffc88d8
Showing with 38 additions and 30 deletions.
  1. +1 −1 bin/varnishtest/tests/u00009.vtc
  2. +2 −2 bin/varnishtest/vtc.c
  3. +1 −1 bin/varnishtest/vtc_process.c
  4. +34 −26 bin/varnishtest/vtc_term.c
@@ -18,4 +18,4 @@ client c1 {
rxresp
} -run
process p1 -need-bytes 300 -screen_dump -write {q} -wait
process p1 -need-bytes 200 -screen_dump -write {q} -wait
View
@@ -727,14 +727,14 @@ test_term(struct vtclog *vl)
FILE *p;
int a, b;
p = popen("tput -T ansi clear 2>&1", "r");
p = popen("tput -T ansi.sys clear 2>&1", "r");
if (p == NULL)
return (0);
a = fgetc(p);
b = fgetc(p);
if (a == 0x1b && b == '[')
return (1);
vtc_log(vl, 3, "No 'ansi' terminfo entry.");
vtc_log(vl, 3, "No 'ansi.sys' terminfo entry.");
return (0);
}
@@ -406,7 +406,7 @@ process_start(struct process *p)
p->pid = fork();
assert(p->pid >= 0);
if (p->pid == 0) {
AZ(setenv("TERM", "ansi", 1));
AZ(setenv("TERM", "ansi.sys", 1));
AZ(unsetenv("TERMCAP"));
assert(dup2(slave, STDIN_FILENO) == STDIN_FILENO);
assert(dup2(slave, STDOUT_FILENO) == STDOUT_FILENO);
View
@@ -63,6 +63,19 @@ term_clear(const struct term *tp)
}
}
static void
term_scroll(const struct term *tp)
{
int i;
char *l;
l = tp->vram[0];
for(i = 0; i < tp->nlin -1; i++)
tp->vram[i] = tp->vram[i + 1];
tp->vram[i] = l;
memset(l, ' ', tp->ncol);
}
void
Term_Dump(const struct term *tp)
{
@@ -77,23 +90,38 @@ term_escape(struct term *tp, int c, int n)
{
int i;
c = tolower(c);
for (i = 0; i < NTERMARG; i++)
if (!tp->arg[i])
tp->arg[i] = 1;
switch(c) {
case 'B':
if (tp->arg[0] > tp->nlin)
vtc_fatal(tp->vl, "ANSI B[%d] outside vram",
tp->arg[0]);
tp->line += tp->arg[0];
while (tp->line >= tp->nlin) {
term_scroll(tp);
tp->line--;
}
break;
case 'h':
// Ignore screen mode selection
break;
case 'H':
if (tp->arg[0] > tp->nlin || tp->arg[1] > tp->ncol)
vtc_fatal(tp->vl, "ANSI H[%d,%d] outside vram",
tp->arg[0], tp->arg[1]);
tp->line = tp->arg[0] - 1;
tp->col = tp->arg[1] - 1;
break;
case 'j':
case 'J':
if (tp->arg[0] != 2)
vtc_fatal(tp->vl, "ANSI J[%d]", tp->arg[0]);
term_clear(tp);
break;
case 'm':
// Ignore Graphic Rendition settings
break;
default:
for (i = 0; i < n; i++)
vtc_log(tp->vl, 4, "ANSI arg %d", tp->arg[i]);
@@ -102,19 +130,6 @@ term_escape(struct term *tp, int c, int n)
}
}
static void
term_scroll(const struct term *tp)
{
int i;
char *l;
l = tp->vram[0];
for(i = 0; i < tp->nlin -1; i++)
tp->vram[i] = tp->vram[i + 1];
tp->vram[i] = l;
memset(l, ' ', tp->ncol);
}
static void
term_char(struct term *tp, char c)
{
@@ -186,6 +201,8 @@ Term_Feed(struct term *tp, const char *b, const char *e)
tp->argp = tp->arg;
memset(tp->arg, 0, sizeof tp->arg);
tp->state = 3;
if (*b == '?')
b++;
break;
case 3:
if (tp->argp - tp->arg >= NTERMARG)
@@ -202,17 +219,8 @@ Term_Feed(struct term *tp, const char *b, const char *e)
b++;
continue;
}
if (islower(*b)) {
term_escape(tp, *b++, tp->argp - tp->arg);
tp->state = 2;
} else if (isupper(*b)) {
term_escape(tp, *b++, tp->argp - tp->arg);
tp->argp = tp->arg;
tp->state = 0;
} else {
vtc_fatal(tp->vl, "ANSI non-letter (0x%02x)",
*b & 0xff);
}
term_escape(tp, *b++, tp->argp - tp->arg);
tp->state = 0;
break;
default:
WRONG("Wrong ansi state");

0 comments on commit 945d2e1

Please sign in to comment.