Commit 4c3ef2df authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Report cursor position in screen-dump, and add "-expect-cursor"

parent 71c29e86
......@@ -55,10 +55,14 @@ process p4 -write "\x1b[H\x1b[2J1\x1b[79C2\x08>\x1b[25;1H3\x1b[25;80H"
process p4 -write "4\x08>\x1b[A\x1b[Cv\x1b[22A^\x1b[79D^\x1b[;2H<\n\n\n\n"
process p4 -write "\n\n\n\n\n\n\n\n\x1b[B\x1b[11B\x08<\x1b[24;Hv\x1b[12;1H"
process p4 -write "111111112222222333333\x0d\x0a111111112"
process p4 -write "222222333333\x0d\x0a111111112222222333"
process p4 -write "333\x0d\x0a111111112222222333333\x0d\x0a\x1b[12"
process p4 -write "222222333333\x0d\x0a111111112222222333333 UTF8: "
process p4 -writehex {c2 a2 20 e2 82 ac 20 f0 9f 90 b0}
process p4 -write "\x0d\x0a111111112222222333333\x0d\x0a\x1b[12"
process p4 -write ";12H\x1b[K\x1b[13;12H\x1b[0K\x1b[14;12H\x1b[1K\x1b"
process p4 -write "[15;12H\x1b[2K\x1b[3;1Hline3 <\x0d\x0a"
process p4 -need-bytes 252 -expect-text 3 1 "line3 <"
process p4 -screen_dump -stop
process p4 -need-bytes 270 -expect-text 3 1 "line3 <"
process p4 -expect-cursor 4 1
process p4 -expect-cursor 4 0
process p4 -expect-cursor 0 1
process p4 -screen-dump -stop
......@@ -205,9 +205,13 @@ static void
term_screen_dump(const struct process *pp)
{
int i;
const teken_pos_t *pos;
for (i = 0; i < pp->nlin; i++)
vtc_dump(pp->vl, 3, "screen", pp->vram[i], pp->ncol);
pos = teken_get_cursor(pp->tek);
vtc_log(pp->vl, 3, "Cursor at line %d column %d",
pos->tp_row + 1, pos->tp_col + 1);
}
static void
......@@ -312,6 +316,23 @@ term_expect_text(struct process *pp,
vtc_log(pp->vl, 4, "found expected text at %d,%d: '%s'", y, x, pat);
}
static void
term_expect_cursor(struct process *pp, const char *lin, const char *col)
{
int x, y;
const teken_pos_t *pos;
pos = teken_get_cursor(pp->tek);
y = strtoul(lin, NULL, 0);
x = strtoul(col, NULL, 0);
if (y != 0 && (y-1) != pos->tp_row)
vtc_fatal(pp->vl, "Cursor on line %d (expected %d)",
pos->tp_row + 1, y);
if (x != 0 && (x-1) != pos->tp_col)
vtc_fatal(pp->vl, "Cursor in column %d (expected %d)",
pos->tp_col + 1, y);
}
/**********************************************************************
* Allocate and initialize a process
*/
......@@ -968,7 +989,15 @@ cmd_process(CMD_ARGS)
av += 3;
continue;
}
if (!strcmp(*av, "-screen_dump")) {
if (!strcmp(*av, "-expect-cursor")) {
AN(av[1]);
AN(av[2]);
term_expect_cursor(p, av[1], av[2]);
av += 2;
continue;
}
if (!strcmp(*av, "-screen_dump") ||
!strcmp(*av, "-screen-dump")) {
term_screen_dump(p);
continue;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment