Beispiel #1
0
static int
tst_display(MENU_ARGS)
{
  int d, c = -1;

  vt_move(1, 1);
  display_head(stdout);
  println("");
  println("Press any key to display its soft-character.  Repeat a key to quit.");

  set_tty_raw(TRUE);
  set_tty_echo(FALSE);

  do {
    d = c;
    c = inchar();
    vt_move(6, 1);
    vt_clear(0);
    if (display_char(stdout, c)) {
      println("");
      printf("Render: %cN%c", ESC, c);  /* use SS2 to invoke G2 into GL */
    }
  } while (c != d);

  restore_ttymodes();
  return MENU_NOHOLD;
}
Beispiel #2
0
/*
 * VT200 and up
 *
 * Test to ensure that 'ech' (erase character) is honored, with no parameter,
 * explicit parameter, and longer than the screen width (to ensure that the
 * terminal doesn't try to wrap-around the erasure).
 */
static int
tst_ECH(MENU_ARGS)
{
    int i;
    int last = max_lines - 4;

    decaln();
    for (i = 1; i <= max_lines; i++) {
        cup(i, min_cols - i - 2);
        do_csi("X");  /* make sure default-parameter works */
        cup(i, min_cols - i - 1);
        printf("*");
        ech(min_cols);
        printf("*");  /* this should be adjacent, in the upper-right corner */
    }

    vt_move(last, 1);
    vt_clear(0);

    vt_move(last, min_cols - (last + 10));
    println("diagonal: ^^ (clear)");
    println("ECH test: there should be E's with a gap before diagonal of **'s");
    println("The lower-right diagonal region should be cleared.  Nothing else.");
    return MENU_HOLD;
}
Beispiel #3
0
/* Test User-Preferred Supplemental Set - VT320 */
static int
tst_DECRQUPSS(MENU_ARGS)
{
  char *report;
  const char *show;

  __(vt_move(1, 1), println("Testing DECRQUPSS/DECAUPSS Window Report"));

  set_tty_raw(TRUE);
  set_tty_echo(FALSE);

  do_csi("&u");
  report = get_reply();
  vt_move(3, 10);
  chrprint(report);
  if ((report = skip_dcs(report)) != 0
      && strip_terminator(report)) {
    if (!strcmp(report, "0!u%5"))
      show = "DEC Supplemental Graphic";
    else if (!strcmp(report, "1!uA"))
      show = "ISO Latin-1 supplemental";
    else
      show = "unknown";
  } else {
    show = SHOW_FAILURE;
  }
  show_result("%s", show);

  restore_ttymodes();
  vt_move(max_lines - 1, 1);
  return MENU_HOLD;
}
Beispiel #4
0
int
any_DSR(MENU_ARGS, const char *text, void (*explain) (char *report))
{
    char *report;
    unsigned pmode = (unsigned) ((*text == '?') ? 1 : 0);

    vt_move(1, 1);
    printf("Testing DSR: %s\n", the_title);

    set_tty_raw(TRUE);
    set_tty_echo(FALSE);

    do_csi("%s", text);
    report = get_reply();
    vt_move(3, 10);
    chrprint(report);
    if ((report = skip_csi(report)) != 0
            && strlen(report) > (1 + pmode)
            && (!pmode || (*report++ == '?'))) {
        if (explain != 0)
            (*explain) (report);
        else
            show_result(SHOW_SUCCESS);
    } else {
        show_result(SHOW_FAILURE);
    }

    restore_ttymodes();
    vt_move(max_lines - 1, 1);
    return MENU_HOLD;
}
Beispiel #5
0
/* Request Terminal State Report */
static int
tst_DECRQTSR(MENU_ARGS)
{
  char *report;
  const char *show;

  vt_move(1, 1);
  println("Testing Terminal State Reports (DECRQTSR/DECTSR)");

  set_tty_raw(TRUE);
  set_tty_echo(FALSE);

  do_csi("1$u");
  report = get_reply();

  vt_move(3, 10);
  chrprint(report);

  if ((report = skip_dcs(report)) != 0
      && strip_terminator(report)
      && !strncmp(report, "1$s", (size_t) 3)) {
    show = SHOW_SUCCESS;
  } else {
    show = SHOW_FAILURE;
  }
  show_result("%s", show);

  restore_ttymodes();
  vt_move(max_lines - 1, 1);
  return MENU_HOLD;
}
Beispiel #6
0
/* VT220 & up.
 */
static int
tst_S8C1T(MENU_ARGS)
{
    char *report;
    int flag = input_8bits;
    int pass;

    vt_move(1, 1);
    println(the_title);

    vt_move(5, 1);
    println("This tests the VT200+ control sequence to direct the terminal to emit 8-bit");
    println("control-sequences instead of <esc> sequences.");

    set_tty_raw(TRUE);
    set_tty_echo(FALSE);

    for (pass = 0; pass < 2; pass++) {
        flag = !flag;
        s8c1t(flag);
        cup(1, 1);
        dsr(6);
        report = instr();
        vt_move(10 + pass * 3, 1);
        printf("8-bit controls %s: ", flag ? "enabled" : "disabled");
        chrprint(report);
        report_ok("1;1R", report);
    }

    restore_ttymodes();
    vt_move(max_lines - 1, 1);
    return MENU_HOLD;
}
Beispiel #7
0
/* Test Window Report - VT340, VT420 */
static int
tst_DECRQDE(MENU_ARGS)
{
  char *report;
  char chr;
  int Ph, Pw, Pml, Pmt, Pmp;

  vt_move(1, 1);
  println("Testing DECRQDE/DECRPDE Window Report");

  set_tty_raw(TRUE);
  set_tty_echo(FALSE);

  do_csi("\"v");
  report = get_reply();
  vt_move(3, 10);
  chrprint(report);

  if ((report = skip_csi(report)) != 0
      && sscanf(report, "%d;%d;%d;%d;%d\"%c",
                &Ph, &Pw, &Pml, &Pmt, &Pmp, &chr) == 6
      && chr == 'w') {
    vt_move(5, 10);
    show_result("lines:%d, cols:%d, left col:%d, top line:%d, page %d",
                Ph, Pw, Pml, Pmt, Pmp);
  } else {
    show_result(SHOW_FAILURE);
  }

  restore_ttymodes();
  vt_move(max_lines - 1, 1);
  return MENU_HOLD;
}
Beispiel #8
0
static int
test_altscrn_47(MENU_ARGS)
{
    vt_move(1,1);
    println(the_title);
    vt_move(3,1);
    println("Test private setmode 47 (to/from alternate screen)");
    vt_move(4,1);
    println("The next screen will be filled with E's down to the prompt.");
    vt_move(7,5);
    decsc();
    vt_move(max_lines-2,1);
    holdit();

    sm("?47");
    decaln(); /* fill the screen */
    vt_move(15,7);
    decsc();
    vt_move(max_lines-2,1);
    ed(0);
    holdit();

    rm("?47");
    decrc();
    check_rc(7,5);
    vt_move(4,1);
    el(2);
    println("The original screen should be restored except for this line.");
    vt_move(max_lines-2,1);
    return MENU_HOLD;
}
Beispiel #9
0
static int
test_altscrn_1049(MENU_ARGS)
{
    vt_move(1,1);
    println(the_title);
    vt_move(3,1);
    println("Test private setmode 1049 (to/from alternate screen)");
    vt_move(4,1);
    println("The next screen will be filled with E's down to the prompt.");
    vt_move(5,1);
    println("unless titeInhibit resource is set, or alternate-screen is disabled.");
    vt_move(7,5);
    decsc();
    vt_move(max_lines-2,1);
    holdit(); /* cursor location will be one line down */

    sm("?1049");  /* this saves the cursor location */
    decaln(); /* fill the screen */
    vt_move(max_lines-2,1);
    ed(0);
    holdit();

    rm("?1049");
    decrc();
    check_rc(max_lines-1,1);
    vt_move(4,1);
    el(2);
    println("The original screen should be restored except for this line");
    vt_move(max_lines-2,1);
    return MENU_HOLD;
}
Beispiel #10
0
/*
 * VT500 & up
 *
 * Test if terminal can control whether the screen is cleared when changing
 * DECCOLM.
 */
static int
tst_DECNCSM(MENU_ARGS)
{
  int last = max_lines - 4;
  char temp[80];

  decaln();
  deccolm(FALSE);
  vt_move(last, 1);
  ruler(last, min_cols);
  vt_clear(0);
  sprintf(temp, "Screen should be cleared (%d-columns)", min_cols);
  println(temp);
  holdit();

  decaln();
  deccolm(TRUE);
  vt_move(last, 1);
  ruler(last, max_cols);
  vt_clear(0);
  sprintf(temp, "Screen should be cleared (%d-columns)", max_cols);
  println(temp);
  holdit();

  decncsm(TRUE);

  decaln();
  deccolm(FALSE);
  vt_move(last, 1);
  ruler(last, min_cols);
  vt_clear(0);
  sprintf(temp, "Screen should be filled (%d-columns)", min_cols);
  println(temp);
  holdit();

  decaln();
  deccolm(TRUE);
  vt_move(last, 1);
  ruler(last, max_cols);
  vt_clear(0);
  sprintf(temp, "Screen should be filled (%d of %d-columns)", min_cols, max_cols);
  println(temp);
  holdit();

  decncsm(FALSE);
  deccolm(FALSE);
  vt_move(last, 1);
  ruler(last, min_cols);
  vt_clear(0);
  sprintf(temp, "Screen should be cleared (%d-columns)", min_cols);
  println(temp);

  return MENU_HOLD;
}
Beispiel #11
0
/*
 * Return updated row-number based on the number of characters printed to the
 * screen, e.g., for test_report_ops() to handle very long results.
 */
int
chrprint2(const char *s, int row, int col)
{
  int i;
  int result = row;
  int tracks = (col += 2);
  char temp[80];

  printf("  ");
  vt_hilite(TRUE);
  printf(" ");
  tracks += 3;

  for (i = 0; s[i] != '\0'; i++) {
    int c = (unsigned char) s[i];
    if (c <= ' ' || c >= '\177') {
      sprintf(temp, "<%d> ", c);
    } else {
      sprintf(temp, "%c ", c);
    }
    tracks += (int) strlen(temp);
    if ((tracks > min_cols) && (col > 1)) {
      vt_move(++result, col);
      tracks = col + (int) strlen(temp);
    }
    fputs(temp, stdout);
  }

  vt_hilite(FALSE);
  return result + 1;
}
Beispiel #12
0
int
tst_softchars(MENU_ARGS)
{
  /* *INDENT-OFF* */
  static MENU my_menu[] = {
      { "Exit",                                              0 },
      { "Download the soft characters (DECDLD)",             tst_DECDLD },
      { "Examine the soft characters",                       tst_display },
      { "Clear the soft characters",                         tst_cleanup },
      { "",                                                  0 }
    };
  /* *INDENT-ON* */

  vt_move(1, 1);
  if (font_string == 0 || *font_string == 0) {
    printf("You did not specify a font-file with the -f option\n");
    return MENU_HOLD;
  }
  do {
    vt_clear(2);
    __(title(0), printf("Soft Character Sets"));
    __(title(2), println("Choose test type:"));
  } while (menu(my_menu));
  return MENU_NOHOLD;
}
Beispiel #13
0
static void
check_rc(int row, int col)
{
    char *report;
    char *params;
    char expected[80];

    sprintf(expected, "%d;%dR", row, col);

    set_tty_raw(TRUE);
    set_tty_echo(FALSE);
    do_csi("6n");
    report = get_reply();
    restore_ttymodes();

    vt_move(row, 1);
    el(2);
    if ((params = skip_csi(report)) == 0
            || strcmp(params, expected) != 0) {
        printf("cursor save/restore %s, got \"%s\", expected \"%s\"",
               SHOW_FAILURE, params, expected);
    } else {
        printf("cursor save/restore %s", SHOW_SUCCESS);
    }
}
Beispiel #14
0
void
bye(void)
{
  /* Force my personal prejudices upon the poor luser   */
  if (LOG_ENABLED)
    fprintf(log_fp, "Cleanup & exit\n");

  default_level();  /* Enter ANSI mode (if in VT52 mode)    */
  decckm(FALSE);  /* cursor keys normal   */
  deccolm(FALSE);   /* 80 col mode          */
  decscnm(FALSE);   /* Normal screen        */
  decom(FALSE); /* Absolute origin mode */
  decawm(TRUE); /* Wrap around on       */
  decarm(TRUE); /* Auto repeat on       */
  decstbm(0, 0);  /* No scroll region     */
  sgr("0");     /* Normal character attributes  */

  /* Say goodbye */

  vt_clear(2);
  vt_move(12, 30);
  printf("That's all, folks!\n");
  printf("\n\n\n");
  inflush();
  close_tty();
  exit(EXIT_SUCCESS);
}
Beispiel #15
0
int
title(int offset)
{
  vt_move(TITLE_LINE + offset, 10);
  if (offset == 0 && *current_menu)
    printf("Menu %s: ", current_menu);
  return 1;     /* used for indenting */
}
Beispiel #16
0
static int
toggle_DECSCL(MENU_ARGS)
{
  int request = cur_level;

  if (max_level <= 1) {
    vt_move(1,1);
    printf("Sorry, terminal supports only VT%d", terminal_id());
    vt_move(max_lines-1,1);
    return MENU_HOLD;
  }

  if (++request > max_level)
    request = 1;
  set_level(request);

  restore_ttymodes();
  return MENU_NOHOLD;
}
Beispiel #17
0
/* Set window title */
static int
test_window_name(MENU_ARGS)
{
    char temp[BUFSIZ];

    vt_move(1,1);
    println("Please enter the new window name.  Newer xterms may beep when setting the title.");
    inputline(temp);
    do_osc("0;%s%c", temp, BEL);
    return MENU_NOHOLD;
}
Beispiel #18
0
/*
 * VT220 & up
 *
 * Test if the terminal can make the cursor invisible
 */
static int
tst_DECTCEM(MENU_ARGS)
{
    vt_move(1, 1);
    rm("?25");
    println("The cursor should be invisible");
    holdit();
    sm("?25");
    println("The cursor should be visible again");
    return MENU_HOLD;
}
Beispiel #19
0
int
tst_DECSTR(MENU_ARGS)
{
  vt_move(1,1);
  println(the_title);
  println("(VT220 & up)");
  println("");
  println("The terminal will now soft-reset");
  holdit();
  decstr();
  return MENU_HOLD;
}
Beispiel #20
0
int
any_decrqpsr(MENU_ARGS, int Ps)
{
  char *report;

  vt_move(1, 1);
  printf("Testing DECRQPSR: %s\n", the_title);

  set_tty_raw(TRUE);
  set_tty_echo(FALSE);

  do_csi("%d$w", Ps);
  report = get_reply();
  vt_move(3, 10);
  chrprint(report);
  if ((report = skip_dcs(report)) != 0) {
    if (strip_terminator(report)
        && *report == Ps + '0'
        && !strncmp(report + 1, "$u", (size_t) 2)) {
      show_result("%s (valid request)", SHOW_SUCCESS);
      switch (Ps) {
      case 1:
        show_DECCIR(report);
        break;
      case 2:
        show_DECTABSR(report);
        break;
      }
    } else {
      show_result(SHOW_FAILURE);
    }
  } else {
    show_result(SHOW_FAILURE);
  }

  restore_ttymodes();
  vt_move(max_lines - 1, 1);
  return MENU_HOLD;
}
Beispiel #21
0
/*
 * VT500 & up
 *
 * Test if the terminal can change the cursor's appearance
 */
static int
tst_DECSCUSR(MENU_ARGS)
{
  size_t n;

  vt_move(1, 1);
  for (n = 0; n < TABLESIZE(tbl_decscusr); ++n) {
    if (n != 0)
      holdit();
    decscusr(tbl_decscusr[n].code);
    println(tbl_decscusr[n].text);
  }
  return MENU_HOLD;
}
Beispiel #22
0
static int
rpt_DECSCUSR(MENU_ARGS)
{
  size_t n;

  vt_move(1, 1);
  for (n = 0; n < TABLESIZE(tbl_decscusr); ++n) {
    if (n != 0)
      holdit();
    vt_clear(2);
    decscusr(tbl_decscusr[n].code);
    (void) any_decrqss(tbl_decscusr[n].text, " q");
  }
  return MENU_HOLD;
}
Beispiel #23
0
static int
tst_DECTST(MENU_ARGS)
{
  vt_move(1,1);
  println(the_title);
  println("");

  if (did_reset)
    println("The terminal is now RESET.  Next, the built-in confidence test");
  else
    printf("The built-in confidence test ");
  printf("will be invoked. ");
  holdit();

  vt_clear(2);
  dectst(1);
  zleep(5000);          /* Wait 5.0 seconds */
  vt_move(10,1);
  println("If the built-in confidence test found any errors, a code");
  printf("%s", "is visible above. ");

  did_reset = FALSE;
  return MENU_HOLD;
}
Beispiel #24
0
/*
 * This changes the CSI code to/from an escape sequence.
 */
static int
toggle_8bit_out(MENU_ARGS)
{
  int old = output_8bits;

  fflush(stdout);
  output_8bits = !output_8bits;
  if (!check_8bit_toggle()) {
    output_8bits = old;
    vt_clear(2);
    vt_move(1,1);
    println("Sorry, this terminal does not support 8-bit output controls");
    return MENU_HOLD;
  }
  return MENU_NOHOLD;
}
Beispiel #25
0
static int
rpt_DECSCUSR(MENU_ARGS)
{
  size_t n;

  vt_move(1, 1);
  for (n = 0; n < TABLESIZE(tbl_decscusr); ++n) {
    char expected[10];
    if (n != 0)
      holdit();
    vt_clear(2);
    decscusr(tbl_decscusr[n].code);
    sprintf(expected, "%d", tbl_decscusr[n].code ? tbl_decscusr[n].code : 1);
    (void) any_decrqss2(tbl_decscusr[n].text, " q", expected);
  }
  return MENU_HOLD;
}
Beispiel #26
0
static int
tst_RIS(MENU_ARGS)
{
  vt_move(1,1);
  println(the_title);
  println("(VT100 & up, not recommended)");
  println("");
  printf ("The terminal will now be RESET. ");
  holdit();
  ris();
  zleep(5000);          /* Wait 5.0 seconds */

  did_reset = TRUE;
  reset_level();
  input_8bits = FALSE;
  output_8bits = FALSE;
  return MENU_HOLD;
}
Beispiel #27
0
static int
test_SGR_0(MENU_ARGS)
{
  vt_move(1, 1);
  println(the_title);
  println("");
  println("ECMA-48 states that SGR 0 \"cancels the effect of any preceding occurrence");
  println("of SGR in the data stream regardless of the setting of the graphic rendition");
  println("combination mode (GRCM)\".");
  println("");
  println("");

  reset_colors();
  printf("You should see only black:");
  sgr("30;40");
  printf("SGR 30 and SGR 40 don't work");
  reset_colors();
  println(":up to here");

  reset_colors();
  printf("You should see only white:");
  sgr("37;47");
  printf("SGR 37 and SGR 47 don't work");
  reset_colors();
  println(":up to here");

  reset_colors();
  printf("You should see text here: ");
  sgr("30;40");
  sgr("0");
  printf("SGR 0 reset works (explicit 0)");
  println("");

  reset_colors();
  printf("................and here: ");
  sgr("37;47");
  sgr("");
  printf("SGR 0 reset works (default param)");
  println("");

  reset_colors();
  holdit();
  return MENU_NOHOLD;
}
Beispiel #28
0
int
tst_bugs(MENU_ARGS)
{
  int i;
  /* *INDENT-OFF* */
  static MENU menutable[] = {
    { "Exit to main menu",                                   0 },
    { "Bug A: Smooth scroll to jump scroll",                 bug_a },
    { "Bug B: Scrolling region",                             bug_b },
    { "Bug C: Wide to narrow screen",                        bug_c },
    { "Bug D: Narrow to wide screen",                        bug_d },
    { "Bug E: Cursor move from double- to single-wide line", bug_e },
    { "Bug F: Column mode escape sequence",                  bug_f },
    { "Wrap around with cursor addressing",                  bug_w },
    { "Erase right half of double width lines",              bug_l },
    { "Funny scroll regions",                                bug_s },
    /* Add more here */
    { "",                                                    0 }
  };
  /* *INDENT-ON* */

  static const char *hmsg[] =
  {
    "Test of known bugs in the DEC VT100 series. The numbering of some of",
    "the bugs (A-F) refers to the article 'VT100 MAGIC' by Sami Tabih in",
    "the 'Proceedings of the DEC Users Society' at St. Louis, Missouri, May",
    "1983. To understand some of the tests, you have to look at the source",
    "code or the article. Of course, a good VT100-compatible terminal",
    "should not have these bugs (or have some means of disabling them)! If",
    "a bug appears, you might want to RESET the terminal before continuing",
    "the test. There is a test of the RESET function in the main menu.",
    ""};

  do {
    vt_clear(2);
    vt_move(1, 1);
    for (i = 0; *hmsg[i]; i++)
      println(hmsg[i]);
    println("");
    println("          Choose bug test number:");
  } while (menu2(menutable, i + 1));
  return MENU_NOHOLD;
}
Beispiel #29
0
static int
tst_DECDLD(MENU_ARGS)
{
  char *s;

  vt_move(1, 1);
  printf("Working...\n");
  for (s = font_string; *s; s++) {
    putchar(*s);
    if (*s == '\n') {
      fflush(stdout);
      padding(20);
    }
  }
  fflush(stdout);
  padding(20);
  printf("...done ");

  printf("%c*%s", ESC, FontName);   /* designate G2 as the DRCS font */
  padding(4);
  fflush(stdout);

  return MENU_HOLD;
}
Beispiel #30
0
/*
 * Request  CSI ? 26 n            keyboard dialect
 * Response CSI ? 27; Ps n
 */
static void
show_KeyboardStatus(char *report)
{
    int pos = 0;
    int code;
    int save;
    const char *show = SHOW_FAILURE;

    if ((code = scanto(report, &pos, ';')) == 27
            && (code = scan_any(report, &pos, 'n')) != 0) {
    /* *INDENT-OFF* */
    switch(code) {
    case  1:  show = "North American/ASCII"; break;
    case  2:  show = "British";              break;
    case  3:  show = "Flemish";              break;
    case  4:  show = "French Canadian";      break;
    case  5:  show = "Danish";               break;
    case  6:  show = "Finnish";              break;
    case  7:  show = "German";               break;
    case  8:  show = "Dutch";                break;
    case  9:  show = "Italian";              break;
    case 10:  show = "Swiss (French)";       break;
    case 11:  show = "Swiss (German)";       break;
    case 12:  show = "Swedish";              break;
    case 13:  show = "Norwegian/Danish";     break;
    case 14:  show = "French/Belgian";       break;
    case 15:  show = "Spanish Int.";         break;
    case 16:  show = "Portugese";            break; /* vt3XX */
    case 19:  show = "Hebrew";               break; /* vt5XX: kermit says 14 */
    case 22:  show = "Greek";                break; /* vt5XX */
    case 28:  show = "Canadian (English)";   break; /* vt4XX */
    case 29:  show = "Turkish Q/Turkish";    break; /* vt5XX */
    case 30:  show = "Turkish F/Turkish";    break; /* vt5XX */
    case 31:  show = "Hungarian";            break; /* vt5XX */
    case 32:  show = "Spanish National";     break; /* vt4XX in PC mode */
    case 33:  show = "Slovak";               break; /* vt5XX */
    case 34:  show = "Czech";                break; /* vt5XX */
    case 35:  show = "Polish";               break; /* vt5XX */
    case 36:  show = "Romanian";             break; /* vt5XX */
    case 38:  show = "SCS";                  break; /* vt5XX */
    case 39:  show = "Russian";              break; /* vt5XX */
    case 40:  show = "Latin American";       break; /* vt5XX */
    default:  show = "unknown";
    }
    /* *INDENT-ON* */

    }
    show_result("%s", show);

    /* vt420 implements additional parameters past those reported by the VT220 */
    save = pos;
    code = scan_any(report, &pos, 'n');
    if (save != pos) {
        vt_move(5, 10);
    /* *INDENT-OFF* */
    switch(code) {
    case 0:  show = "keyboard ready"; break;
    case 3:  show = "no keyboard";    break;
    case 8:  show = "keyboard busy";  break;
    default: show = "unknown keyboard status";
    }
    /* *INDENT-ON* */

        show_result("%s", show);

        vt_move(6, 10);
    /* *INDENT-OFF* */
    switch (scan_any(report, &pos, 'n')) {
    case 0:  show = "LK201"; break;
    case 1:  show = "LK401"; break;
    default: show = "unknown keyboard type";
    }
    /* *INDENT-ON* */

        show_result("%s", show);
    }
}