Exemplo n.º 1
0
static int tty_esc_type_esc(tty_t t, char c, int pos)
{
	switch(c)
	{
		case '[': /* CSI START */
			t->escape_type = ESC_TYPE_CSI;
			cprintf("Started CSI sequence");
			return ESC_RES_CNT;
		case '(': /* Define G0 character set */
		case ')': /* Define G1 character set */
		case ']': /* OS command (change colors) */
			return ESC_RES_CNT;
		case 'D': /* Line feed */
		case 'E': /* New line */
			tty_new_line(t);
			return ESC_RES_DNE;

		case 'H': /* Set tab stop at curr pos */
			cprintf("Old tab stop: %d", t->tab_stop);
			t->tab_stop = t->cursor_pos % CONSOLE_COLS;
			cprintf("New tab stop: %d", t->tab_stop);
			return ESC_RES_DNE;
		case '7': /* Save tty state */
			tty_save(t);
			return ESC_RES_DNE;
		case '8': /* restore tty state */
			tty_restore(t);
			return ESC_RES_DNE;
		case 'Z': /* Identify self */
			tty_handle_raw(0x1B, t);
			tty_handle_raw('/', t);
			tty_handle_raw('Z', t);
			return ESC_RES_DNE;
			/* Unimplemented escape sequences */
		case '#': /* Possible alignment test */

		case 'c': /* Reset the terminal properties */


		case 'M': /* Reverse line feed */

		case '>': /* Set numeric keyboard mode */

		case '=': /* Set application keyboard mode */

		default:
			/* Unhandled */
			return ESC_RES_ERR;
	}
}
Exemplo n.º 2
0
int
recinput(char *arqinput, char *argv[])
{
int	fdm, c;
pid_t	pid;
struct termios	orig_termios;
struct winsize	size;

   if (! isatty(0) || ! isatty(1))
   {
	msg("stdin and stdout must be a terminal");
	return ERRO;
   }
   input = criarq("", arqinput, "");
   if (input == NULL)
      return ERRO;

   if (tty_save(STDIN_FILENO) == ERRO)
	return ERRO;

   pid = pty_fork2(&fdm, slave_name);

   if (pid < 0)
   {
	return ERRO;
   }
   else 
   if (pid == 0) 
   {		/* child */
	if (execv(argv[0], argv) < 0)
	{
	   msg("can't execv: %s");
	   return ERRO;
	}
    }

   if (tty_raw(STDIN_FILENO) < 0)	/* user's tty to raw mode */
   {
	msg("tty_raw error");
        return ERRO;
   }

   c = loop1(fdm);	/* copies stdin -> ptym, ptym -> stdout */
   waitpid(pid, NULL, 0);
   fclose(input);
   close(fdm); 
   tty_copy(STDIN_FILENO);
   return c;
}