aboutsummaryrefslogtreecommitdiff
path: root/sys/cmd/rc/prompt.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/cmd/rc/prompt.c')
-rw-r--r--sys/cmd/rc/prompt.c101
1 files changed, 0 insertions, 101 deletions
diff --git a/sys/cmd/rc/prompt.c b/sys/cmd/rc/prompt.c
deleted file mode 100644
index e474c14..0000000
--- a/sys/cmd/rc/prompt.c
+++ /dev/null
@@ -1,101 +0,0 @@
-#include "rc.h"
-#include "fns.h"
-#include "io.h"
-#include "exec.h"
-#include "getflags.h"
-#include <assert.h>
-#include <errno.h>
-#include <stdio.h>
-#include <sys/stat.h>
-
-#include "linenoise.h"
-
-#define DEBUG(f, a...) \
- if(0){}else{pfmt(err, "\n%s: "f, __FUNCTION__, ## a);flush(err);}
-
-#define HISTORY_PATH "~/.local/rc/history"
-
-#define COMPLETE_FN "complete"
-#define COMPLETE_RESULTS "rc_complete_results"
-
-static
-char*
-completion_matches(const char *s, int i)
-{
- Word *w;
-
- for(w=vlook(COMPLETE_RESULTS)->val; w; w=w->next, i--)
- if(!i)
- return strdup(w->word);
- return nil;
-}
-
-static
-void
-completion(const char *text, linenoiseCompletions *lc)
-{
- linenoiseAddCompletion(lc, "test");
-}
-
-static
-void
-savehist(void)
-{
- linenoiseHistorySave(HISTORY_PATH);
-}
-
-static
-void
-readline(void)
-{
- static int first = 1;
- Io *f = runq->cmdfd;
- char *s;
- long n;
-
- if(first){
- linenoiseSetMultiLine(1);
- linenoiseSetCompletionCallback(completion);
-
- linenoiseHistorySetMaxLen(10000);
-
- /* history */
- if(linenoiseHistoryLoad(HISTORY_PATH)!=0 && errno!=ENOENT)
- pfmt(err, "rc: loadhistory: %s\n", strerror(errno));
-
- atexit(savehist);
- first = 0;
- }
-
- s = linenoise(promptstr);
- if(!s)
- return;
-
- n = strlen(s);
- assert(n < NBUF-1);
- strcpy(f->buf, s);
- f->buf[n++] = '\n';
- f->bufp = f->buf;
- f->ebuf = f->buf+n;
-
- linenoiseHistoryAdd(s);
- free(s);
-}
-
-void
-pprompt(void)
-{
- Var *prompt;
-
- if(runq->iflag){
- flush(err);
- readline();
- prompt = vlook("prompt");
- if(prompt->val && prompt->val->next)
- promptstr = prompt->val->next->word;
- else
- promptstr="\t";
- }
- runq->lineno++;
- doprompt = 0;
-}