aboutsummaryrefslogtreecommitdiff
path: root/sys/cmd/rc/prompt.c
blob: 1122d544ae46a640a57aa7f81af6923e2838bb43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "rc.h"

/* static char promptbuf[7] = {'>', ' ', 0, ' ' , ' ', ' ', 0}; */
static char *base= "\x1b[1;31m" ">" "\x1b[0;0m" " ", *promptstr;

void
resetprompt(void)
{
    promptstr = base;
}

int
prompt(ushort *flag)
{
    int f = *flag;

    if(f){
        if(!readline(promptstr)){
            runner->flag.eof = 1;
            return 0;
        }
        if(runner->cmd.io->e[-1] == '\n'){
            runner->cmd.io->e[-1] = 0;
            addhistory(runner->cmd.io->b);
            runner->cmd.io->e[-1] = '\n';
        }

        write(mapfd(0), "\n\r", 2);
        promptstr = "    ";

        runner->line++;
        *flag = 0;
    }

    return 1;
}