diff options
author | Nicholas <nbnoll@eml.cc> | 2021-11-12 09:22:01 -0800 |
---|---|---|
committer | Nicholas <nbnoll@eml.cc> | 2021-11-12 09:22:01 -0800 |
commit | ce05175372a9ddca1a225db0765ace1127a39293 (patch) | |
tree | 5988b4d4f6b402e4953945886fc90aae11203df6 /src/cmd/rc/prompt.c | |
parent | b375f3cdedb5b0e08745d100b40e38d2f8396a58 (diff) |
chore: simplified organizational structurelaptop
Diffstat (limited to 'src/cmd/rc/prompt.c')
-rw-r--r-- | src/cmd/rc/prompt.c | 36 |
1 files changed, 36 insertions, 0 deletions
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; +} |