From 566d54fe549286895fdef8aa9f385686405dd290 Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Wed, 13 Oct 2021 16:46:20 -0700 Subject: RM(rc): old code. too many assumptions baked in --- sys/cmd/rc/prompt.c | 101 ---------------------------------------------------- 1 file changed, 101 deletions(-) delete mode 100644 sys/cmd/rc/prompt.c (limited to 'sys/cmd/rc/prompt.c') 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 -#include -#include -#include - -#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; -} -- cgit v1.2.1