aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/rc/prompt.c
blob: 5579b0d6dedbe85fc8f0db6d6fcf698ed9ff501d (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
#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(void)
{
    if(runner->flag.user){
        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++;
    }

    return 1;
}