From ce05175372a9ddca1a225db0765ace1127a39293 Mon Sep 17 00:00:00 2001 From: Nicholas Date: Fri, 12 Nov 2021 09:22:01 -0800 Subject: chore: simplified organizational structure --- src/cmd/rc/prompt.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/cmd/rc/prompt.c (limited to 'src/cmd/rc/prompt.c') diff --git a/src/cmd/rc/prompt.c b/src/cmd/rc/prompt.c new file mode 100644 index 0000000..1122d54 --- /dev/null +++ b/src/cmd/rc/prompt.c @@ -0,0 +1,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; +} -- cgit v1.2.1