~sircmpwn/imrsh

da592a35cb2d7b95a89b257dc26de618da640d9e — Drew DeVault 4 years ago 63bd28d
add c-l (clear)
1 files changed, 18 insertions(+), 0 deletions(-)

M src/interactive.c
M src/interactive.c => src/interactive.c +18 -0
@@ 153,6 153,7 @@ imrsh_swap(struct imrsh_interactive *imrsh)
		imrsh->read_buffer->data[imrsh->cur - 1];
	imrsh->read_buffer->data[imrsh->cur - 1] = x;
	tickit_term_move(imrsh->tt, 0, -2);
	tickit_term_setpen(imrsh->tt, imrsh->pens._default);
	tickit_term_printf(imrsh->tt, "%c%c",
			imrsh->read_buffer->data[imrsh->cur - 2],
			imrsh->read_buffer->data[imrsh->cur - 1]);


@@ 160,6 161,21 @@ imrsh_swap(struct imrsh_interactive *imrsh)
}

static void
imrsh_clear(struct imrsh_interactive *imrsh)
{
	tickit_term_clear(imrsh->tt);
	tickit_term_goto(imrsh->tt, 0, 0);
	tickit_term_setpen(imrsh->tt, imrsh->pens._default);
	mrsh_buffer_append_char(imrsh->read_buffer, '\0');
	tickit_term_printf(imrsh->tt, "%s%s",
			imrsh->prompt, imrsh->read_buffer->data);
	--imrsh->read_buffer->len;
	tickit_term_goto(imrsh->tt, 0, 0);
	tickit_term_printf(imrsh->tt, "%s", imrsh->prompt); /* minor hack */
	tickit_term_move(imrsh->tt, 0, imrsh->cur);
}

static void
imrsh_exit(struct imrsh_interactive *imrsh)
{
	imrsh->commit = true;


@@ 205,6 221,8 @@ imrsh_process_key(struct imrsh_interactive *imrsh, TickitKeyEventInfo *info)
		imrsh_delete_all(imrsh);
	} else if (strcmp(info->str, "C-t") == 0) {
		imrsh_swap(imrsh);
	} else if (strcmp(info->str, "C-l") == 0) {
		imrsh_clear(imrsh);
	} else if (strcmp(info->str, "C-d") == 0) {
		if (imrsh->read_buffer->len == 0) {
			imrsh_exit(imrsh);