Exemple #1
0
static void insert_char(char *pos, char c, uint8_t end)
{
	char tmp;

	/* Echo back to console */
	uart_poll_out(uart_console_dev, c);

	if (end == 0) {
		*pos = c;
		return;
	}

	tmp = *pos;
	*(pos++) = c;

	cursor_save();

	while (end-- > 0) {
		uart_poll_out(uart_console_dev, tmp);
		c = *pos;
		*(pos++) = tmp;
		tmp = c;
	}

	/* Move cursor back to right place */
	cursor_restore();
}
Exemple #2
0
void		del(char **str, int *pos,
		    UNUSED t_head *history,
		    UNUSED int *i_history)
{
  if ((*str) && *pos < (int)strlen(*str))
    {
      edit_str(str, pos, 1);
      cursor_save();
      cursor_forward(strlen(*str) - *pos);
      cursor_backward(1);
      cursor_erase(strlen(*str) + 1);
      cursor_restore();
      cursor_save();
      fflush(stdout);
      write(1, "\r", 1);
      write(1, history->prompt, strlen(history->prompt));
      write(1, *str, strlen(*str));
      cursor_restore();
      fflush(stdout);
    }
}
Exemple #3
0
void		backspace(char **str, int *pos,
			  UNUSED t_head *history,
			  UNUSED int *i_history)
{
  if (*pos > 0)
    {
      edit_str(str, pos, 0);
      --*pos;
      cursor_save();
      cursor_forward(strlen(*str) - *pos);
      cursor_backward(1);
      cursor_erase(1);
      cursor_restore();
      cursor_backward(1);
      cursor_erase(1);
      cursor_save();
      fflush(stdout);
      write(1, "\r", 1);
      write(1, history->prompt, strlen(history->prompt));
      write(1, *str, strlen(*str));
      cursor_restore();
      fflush(stdout);
    }
}
Exemple #4
0
static void del_char(char *pos, uint8_t end)
{
	uart_poll_out(uart_console_dev, '\b');

	if (end == 0) {
		uart_poll_out(uart_console_dev, ' ');
		uart_poll_out(uart_console_dev, '\b');
		return;
	}

	cursor_save();

	while (end-- > 0) {
		*pos = *(pos + 1);
		uart_poll_out(uart_console_dev, *(pos++));
	}

	uart_poll_out(uart_console_dev, ' ');

	/* Move cursor back to right place */
	cursor_restore();
}