aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/rc/prompt.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/rc/prompt.c')
-rw-r--r--src/cmd/rc/prompt.c36
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;
+}