Beispiel #1
0
void brl_destroy(brl_t *brl)
{
    if (brl != NULL) {
        brl_hide_prompt(brl);
        brl_free(brl->prompt);
        brl_free(brl->buf);
        brl_free(brl->saved);
        brl_free(brl->yank);
        brl_free(brl->dbg_buf);
        ringbuf_purge(&brl->h);
        cleanup_terminal(brl);

        brl_free(brl);
    }
}
Beispiel #2
0
int brl_read_line(brl_t *brl, char *buf, size_t size)
{
    if (brl->ml == NULL && brl->ml_ops == NULL) {
        reset_input(brl);
        enable_rawmode(brl);
        brl_show_prompt(brl);
        redraw_prompt(brl);
        _brl_process_input(brl);

        if (brl->data > 0)
            snprintf(buf, size, "%s", brl->buf);
        else
            buf[0] = '\0';

        brl_hide_prompt(brl);
        restore_rawmode(brl);

        return brl->data;
    }
    else {
        errno = EINPROGRESS;
        return -1;
    }
}
Beispiel #3
0
static void hide_prompt(client_t *c)
{
    if (c->brl != NULL)
        brl_hide_prompt(c->brl);
}