Esempio n. 1
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;
}
Esempio n. 2
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;
}
Esempio n. 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;
}
Esempio n. 4
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;
}
Esempio n. 5
0
File: xterm.c Progetto: akat1/impala
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);
    }
}
Esempio n. 6
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;
}
Esempio n. 7
0
int tty_control()
{
    ctty = NULL;

    if (!isatty(STDIN_FILENO) || !isatty(STDOUT_FILENO)) {
      /* get controlling terminal */
      char *program_name = "mpg321";
      if ((ctty = fopen((char *)ctty_path(), "r+")) == NULL) {
	fprintf(stderr, "%s: failed to get controlling terminal\n",program_name );
        exit(EXIT_FAILURE);
      }
    }
    if (!isatty(STDIN_FILENO) && ctty) {
        tty_in = ctty;
        TTY_FILENO = fileno(tty_in);
    } else {
        tty_in = stdin;
        TTY_FILENO = STDIN_FILENO;
    }
    if (!isatty(STDOUT_FILENO) && ctty)
        tty_out = ctty;
    else
        tty_out = stdout;

    set_tty_raw();
    return 0;
	
}
Esempio n. 8
0
/* Grab a character from input without requiring the return key. If the
   character is ASCII \033, get more characters and assign certain sequences
   special return codes. Note that this function works best with raw input. */
static int tless_getch(void)
{
	int input;

	set_tty_raw();

	input = getc(inp);
	/* Detect escape sequences (i.e. arrow keys) and handle
	   them accordingly */

	if (input == '\033' && getc(inp) == '[') {
		input = getc(inp);
		set_tty_cooked();
		if (input == REAL_KEY_UP)
			return KEY_UP;
		else if (input == REAL_KEY_DOWN)
			return KEY_DOWN;
		else if (input == REAL_KEY_RIGHT)
			return KEY_RIGHT;
		else if (input == REAL_KEY_LEFT)
			return KEY_LEFT;
		else if (input == REAL_PAGE_UP)
			return PAGE_UP;
		else if (input == REAL_PAGE_DOWN)
			return PAGE_DOWN;
	}
	/* The input is a normal ASCII value */
	else {
		set_tty_cooked();
		return input;
	}
	return 0;
}
Esempio n. 9
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;
}
Esempio n. 10
0
File: xterm.c Progetto: akat1/impala
static int
test_report_ops(MENU_ARGS)
{
    char *report;
    int row = 3;
    int col = 10;

    vt_move(1,1);
    println("Test of Window reporting.");
    set_tty_raw(TRUE);
    set_tty_echo(FALSE);

    vt_move(row++,1);
    println("Report icon label:");
    vt_move(row, col);
    brc(20, 't'); /* report icon label */
    report = instr();
    row = chrprint2(report, row, col);

    vt_move(row++,1);
    println("Report window label:");
    vt_move(row, col);
    brc(21, 't'); /* report window label */
    report = instr();
    row = chrprint2(report, row, col);

    vt_move(row++,1);
    println("Report size of window (chars):");
    vt_move(row++, col);
    brc(18, 't'); /* report window's text-size */
    report = instr();
    chrprint(report);

    vt_move(row++,1);
    println("Report size of window (pixels):");
    vt_move(row++, col);
    brc(14, 't'); /* report window's pixel-size */
    report = instr();
    chrprint(report);

    vt_move(row++,1);
    println("Report position of window (pixels):");
    vt_move(row++, col);
    brc(13, 't'); /* report window's pixel-size */
    report = instr();
    chrprint(report);

    vt_move(row++,1);
    println("Report state of window (normal/iconified):");
    vt_move(row, col);
    brc(11, 't'); /* report window's pixel-size */
    report = instr();
    chrprint(report);

    vt_move(20,1);
    restore_ttymodes();
    return MENU_HOLD;
}
Esempio n. 11
0
File: setup.c Progetto: akat1/impala
static int
check_8bit_toggle(void)
{
  char *report;

  set_tty_raw(TRUE);
  cup(1,1); dsr(6);
  padding(5); /* FIXME: may not be needed */
  report = get_reply();
  restore_ttymodes();

  if ((report = skip_csi(report)) != 0
   && !strcmp(report, "1;1R"))
    return TRUE;
  return FALSE;
}
Esempio n. 12
0
File: setup.c Progetto: akat1/impala
/*
 * Determine the current and maximum operating levels of the terminal
 */
static void
find_levels(void)
{
  char *report;

  set_tty_raw(TRUE);
  set_tty_echo(FALSE);

  da();
  report = get_reply();
  if (!strcmp(report, "\033/Z")) {
    cur_level =
    max_level = 0; /* must be a VT52 */
  } else if ((report = skip_csi(report)) == 0
   || strncmp(report, "?6", 2)
   || !isdigit(report[2])
   || report[3] != ';') {
    cur_level =
    max_level = 1; /* must be a VT100 */
  } else { /* "CSI ? 6 x ; ..." */
    cur_level =
    max_level = report[2] - '0'; /* VT220=2, VT320=3, VT420=4 */
    if (max_level >= 4) {
      decrqss("\"p");
      report = get_reply();
      if ((report = skip_dcs(report)) != 0
       && isdigit(*report++) /* 0 or 1 (by observation, though 1 is an err) */
       && *report++ == '$'
       && *report++ == 'r'
       && *report++ == '6'
       && isdigit(*report))
          cur_level = *report - '0';
    }
  }

  if (LOG_ENABLED) {
    fprintf(log_fp, "Max Operating Level: %d\n", max_level);
    fprintf(log_fp, "Cur Operating Level: %d\n", cur_level);
  }

  restore_ttymodes();
}
Esempio n. 13
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;
}
Esempio n. 14
0
static int
tst_DECUDK(MENU_ARGS)
{
    int key;
  /* *INDENT-OFF* */
  static struct {
    int code;
    const char *name;
  } keytable[] = {
    /* xterm programs these: */
    { 11, "F1" },
    { 12, "F2" },
    { 13, "F3" },
    { 14, "F4" },
    { 15, "F5" },
    /* vt420 programs these: */
    { 17, "F6" },
    { 18, "F7" },
    { 19, "F8" },
    { 20, "F9" },
    { 21, "F10" },
    { 23, "F11" },
    { 24, "F12" },
    { 25, "F13" },
    { 26, "F14" },
    { 28, "F15" },
    { 29, "F16" },
    { 31, "F17" },
    { 32, "F18" },
    { 33, "F19" },
    { 34, "F20" } };
  /* *INDENT-ON* */

    for (key = 0; key < TABLESIZE(keytable); key++) {
        char temp[80];
        const char *s;
        temp[0] = '\0';
        for (s = keytable[key].name; *s; s++)
            sprintf(temp + strlen(temp), "%02x", *s & 0xff);
        do_dcs("1;1|%d/%s", keytable[key].code, temp);
    }

    vt_move(1, 1);
    println(the_title);
    println("Press 'q' to quit.  Function keys should echo their labels.");
    println("(On a DEC terminal you must press SHIFT as well).");

    set_tty_raw(TRUE);
    set_tty_echo(FALSE);

    for (;;) {
        char *report = instr();
        if (*report == 'q')
            break;
        vt_move(5, 10);
        vt_clear(0);
        chrprint(report);
    }

    do_dcs("0");  /* clear all keys */

    restore_ttymodes();
    vt_move(max_lines - 1, 1);
    return MENU_HOLD;
}