From: pfalstad@phoenix.Princeton.EDU (Paul John Falstad) Newsgroups: alt.sources Subject: zsh - ksh/tcsh-like shell (part 6 of 8) Message-ID: <4748@idunno.Princeton.EDU> Date: 14 Dec 90 23:32:40 GMT ---cut here---cut here---cut here--- - } - zerr("warning: undefined signal name: SIG%s",s+4); -} - -void unsettrap(char *s) -{ -int t0; - - if (strncmp(s,"TRAP",4)) - return; - for (t0 = 0; t0 != SIGCOUNT+2; t0++) - if (!strcmp(s+4,sigs[t0])) - { - if (jobbing && (t0 == SIGTTOU || t0 == SIGTSTP || t0 == SIGTTIN - || t0 == SIGPIPE)) - { - zerr("can't trap SIG%s in interactive shells",s); - return; - } - sigtrapped[t0] = 0; - if (t0 == SIGINT) - intr(); - else if (t0 && t0 < SIGCOUNT && t0 != SIGCHLD) - signal(t0,SIG_DFL); - return; - } - zerr("warning: undefined signal name: SIG%s",s+4); -} - -void dotrap(int sig) -{ -char buf[16]; -list l; -int sav; - - sav = sigtrapped[sig]; - if (sav == 2) - return; - sigtrapped[sig] = 2; - sprintf(buf,"TRAP%s",sigs[sig]); - if (l = gethnode(buf,shfunchtab)) - newrunlist(l); - sigtrapped[sig] = sav; -} - -/* get the text corresponding to a command */ - -char *gettext(comm comm) -{ -char *s,*t; - - switch(comm->type) - { - case SIMPLE: - return getsimptext(comm); - case SUBSH: - t = getltext(comm->left); - s = tricat("(",t,")"); - free(t); - return s; - case CURSH: - case SHFUNC: - t = getltext(comm->left); - s = tricat("{",t,"}"); - free(t); - return s; - case CFOR: - return getfortext((struct fornode *) comm->info,comm); - case CWHILE: - return getwhiletext((struct whilenode *) comm->info); - case CREPEAT: - return getrepeattext((struct repeatnode *) comm->info); - case CIF: - return getiftext((struct ifnode *) comm->info); - case CCASE: - return getcasetext((struct casenode *) comm->info,comm->args); - case CSELECT: - return getfortext((struct fornode *) comm->info,comm); - default: - return strdup("(...)"); - } - return NULL; -} - -char *getltext(list l) -{ -char *s,*t,*u; - - s = getl2text(l->left); - if (l->type == ASYNC) - { - t = dyncat(s," &"); - free(s); - s = t; - } - if (!l->right) - return s; - t = getltext(l->right); - u = tricat(s,(l->type == SYNC) ? "\n" : "",t); - free(s); - free(t); - return u; -} - -char *getl2text(list2 l) -{ -char *s,*t,*u; - - s = getptext(l->left); - if (!l->right) - return s; - t = getl2text(l->right); - u = tricat(s,(l->type == ORNEXT) ? " || " : " && ",t); - free(s); - free(t); - return u; -} - -char *getptext(pline p) -{ -char *s,*t,*u; - - s = gettext(p->left); - if (!p->right) - return s; - t = getptext(p->right); - u = tricat(s," | ",t); - free(s); - free(t); - return u; -} - -char *getsimptext(comm comm) -{ -int len = 0; -Node n; -char *fstr[] = { - ">",">!",">>",">>!","<","<<","<&",">&",">&-" - }; -struct fnode *f; -char *s,*t,u = '='; - - for (n = comm->args->first; n; n = n->next) - len += strlen(n->dat)+1; - if (comm->vars) - for (n = comm->vars->first; n; n = n->next) - len += strlen(n->dat)+1; - for (n = comm->redir->first; n; n = n->next) - { - f = n->dat; - switch(f->type) - { - case WRITE: case WRITENOW: case APP: case APPNOW: case READ: - len += strlen(fstr[f->type])+strlen(f->u.name)+8; - break; - case HEREDOC: case MERGE: case MERGEOUT: - len += strlen(fstr[f->type])+10; - break; - case CLOSE: - len += 10; - break; - case INPIPE: - case OUTPIPE: - len += strlen(f->u.name)+10; - break; - } - } - len += strlen(comm->cmd); - s = t = zalloc(len+5); - if (comm->vars) - for (n = comm->vars->first; n; n = n->next) - { - strucpy(&t,n->dat); - *t++ = u; - u = ('='+' ')-u; - } - strucpy(&t,comm->cmd); - *t++ = ' '; - for (n = comm->args->first; n; n = n->next) - { - strucpy(&t,n->dat); - *t++ = ' '; - } - for (n = comm->redir->first; n; n = n->next) - { - f = n->dat; - switch(f->type) - { - case WRITE: case WRITENOW: case APP: case APPNOW: case READ: - if (f->fd1 != ((f->type == READ) ? 0 : 1)) - *t++ = '0'+f->fd1; - strucpy(&t,fstr[f->type]); - *t++ = ' '; - strucpy(&t,f->u.name); - *t++ = ' '; - break; - case HEREDOC: case MERGE: case MERGEOUT: - if (f->fd1 != ((f->type == MERGEOUT) ? 1 : 0)) - *t++ = '0'+f->fd1; - strucpy(&t,fstr[f->type]); - *t++ = ' '; - sprintf(t,"%d ",f->u.fd2); - t += strlen(t); - break; - case CLOSE: - *t++ = '0'+f->fd1; - strucpy(&t,">&- "); - break; - case INPIPE: - case OUTPIPE: - if (f->fd1 != ((f->type == INPIPE) ? 0 : 1)) - *t++ = '0'+f->fd1; - strucpy(&t,(f->type == INPIPE) ? "< " : "> "); - strucpy(&t,f->u.name); - strucpy(&t," "); - len += strlen(f->u.name)+6; - break; - } - } - t[-1] = '\0'; - return s; -} - -char *getfortext(struct fornode *n,comm comm) -{ -char *s,*t,*u,*v; - - s = getltext(n->list); - u = dyncat((comm->type == CFOR) ? "for " : "select ",n->name); - if (comm->args) - { - t = makehlist(comm->args,0); - v = tricat(u," in ",t); - free(u); - free(t); - u = v; - } - v = dyncat(u,"\n do "); - free(u); - u = tricat(v,s,"\n done"); - free(v); - free(s); - return u; -} - -char *getwhiletext(struct whilenode *n) -{ -char *s,*t,*u,*v; - - t = getltext(n->cont); - v = getltext(n->loop); - s = tricat((!n->cond) ? "while " : "until ",t,"\n do "); - u = tricat(s,v,"\n done"); - free(s); - free(t); - free(v); - return u; -} - -char *getrepeattext(struct repeatnode *n) -{ -char buf[100]; -char *s,*t,*u; - - s = getltext(n->list); - sprintf(buf,"%d",n->count); - t = tricat("repeat ",buf," do "); - u = tricat(t,s,"\n done"); - free(s); - free(t); - return u; -} - -char *getiftext(struct ifnode *n) -{ -int fst = 1; -char *v = strdup(""); -char *s,*t,*u,*w; - - while (n && n->ifl) - { - s = getltext(n->ifl); - t = getltext(n->thenl); - u = tricat((fst) ? "if " : "elif ",s,"\n then "); - w = tricat(u,t,"\n "); - free(s); - free(t); - free(u); - s = dyncat(v,w); - free(v); - free(w); - v = s; - fst = 0; - n = n->next; - } - if (n) - { - s = getltext(n->thenl); - t = tricat(v,"else ",s); - u = dyncat(t,"\n fi"); - free(s); - free(t); - free(v); - return u; - } - u = dyncat(v,"\n fi"); - free(v); - return u; -} - -char *getcasetext(struct casenode *n,table l) -{ -char *s,*t,*u,*v; - - s = tricat("case ",l->first->dat," in "); - while (n) - { - u = getltext(n->list); - t = tricat(n->pat,") ",u); - v = tricat(s,t," ;;\n"); - free(s); - free(t); - free(u); - s = v; - n = n->next; - } - t = dyncat(s,"esac\n"); - free(s); - return t; -} - -/* copy t into *s and update s */ - -void strucpy(char **s,char *t) -{ -char *u = *s; - - while (*u++ = *t++); - *s = u-1; -} - -void checkrmall(void) -{ - fflush(stdin); - fprintf(stderr,"zsh: are you sure you want to delete " - "all the files? "); - fflush(stderr); - ding(); - errflag |= !getquery(); -} - -int getquery(void) -{ -char c; -int yes = 0; - - setcbreak(); - if (read(SHTTY,&c,1) == 1 && (c == 'y' || c == 'Y')) - yes = 1; - unsetcbreak(); - if (c != '\n') - write(2,"\n",1); - return yes; -} - -static int d; -static char *guess,*best; - -void spscan(char *s,char *junk) -{ -int nd; - - nd = spdist(s,guess); - if (nd <= d && nd != 3) - { - best = s; - d = nd; - } -} - -/* spellcheck a command */ - -void spckcmd(char **s) -{ -char *t; - - if (gethnode(*s,chtab) || gethnode(*s,shfunchtab)) - return; - for (t = *s; *t; t++) - if (*t == '/') - return; - if (access(*s,F_OK) == 0) - return; - best = NULL; - guess = *s; - d = 3; - listhtable(chtab,spscan); - listhtable(shfunchtab,spscan); - if (best) - { - fprintf(stderr,"zsh: correct to `%s' (y/n)? ",best); - fflush(stderr); - ding(); - if (getquery()) - { - free(*s); - *s = strdup(best); - } - } -} - -void addlocal(char *s) -{ - if (locallist) - addnode(locallist,strdup(s)); -} - -/* perform pathname substitution on a PATH or CDPATH component */ - -void pathsub(char **s) -{ - if (**s == '=') - **s = Equals; - if (**s == '~') - **s = Tilde; - filesub((void **) s); -} - -#ifndef STRFTIME -int strftime(char *buf,int bufsize,char *fmt,struct tm *tm) -{ -char *astr[] = {"Sun","Mon","Tue","Wed","Thu","Fri","Sat"}; -char *estr[] = {"Jan","Feb","Mar","Apr","May","Jun","Jul", - "Aug","Sep","Oct","Nov","Dec"}; -char *lstr[] = {"12"," 1"," 2"," 3"," 4"," 5"," 6"," 7"," 8"," 9","10","11"}; - - while (*fmt) - if (*fmt == '%') - { - fmt++; - switch(*fmt++) - { - case 'a': - strucpy(&buf,astr[tm->tm_wday]); - break; - case 'b': - strucpy(&buf,estr[tm->tm_mon]); - break; - case 'd': - *buf++ = '0'+tm->tm_mday/10; - *buf++ = '0'+tm->tm_mday%10; - break; - case 'e': - *buf++ = (tm->tm_mday > 9) ? '0'+tm->tm_mday/10 : ' '; - *buf++ = '0'+tm->tm_mday%10; - break; - case 'k': - *buf++ = (tm->tm_hour > 9) ? '0'+tm->tm_hour/10 : ' '; - *buf++ = '0'+tm->tm_hour%10; - break; - case 'l': - strucpy(&buf,lstr[tm->tm_hour%12]); - break; - case 'm': - *buf++ = '0'+tm->tm_mon/10; - *buf++ = '0'+tm->tm_mon%10; - break; - case 'M': - *buf++ = '0'+tm->tm_min/10; - *buf++ = '0'+tm->tm_min%10; - break; - case 'p': - *buf++ = (tm->tm_hour > 11) ? 'P' : 'A'; - *buf++ = 'M'; - break; - case 'S': - *buf++ = '0'+tm->tm_sec/10; - *buf++ = '0'+tm->tm_sec%10; - break; - case 'y': - *buf++ = '0'+tm->tm_year/10; - *buf++ = '0'+tm->tm_year%10; - break; - default: - exit(20); - } - } - else - *buf++ = *fmt++; - *buf = '\0'; - return 0; -} -#endif - -#ifndef PUTENV -int putenv(char *a) -{ -char *b = a; - - while (*a++ != '='); - a[-1] = '\0'; - setenv(strdup(b),strdup(a)); - free(b); - return 0; -} -#endif - -int ppcount(void) -{ -Node n; -int val = -1; - - for (n = pparms->first; n; n = n->next,val++); - return val; -} - End of utils.c echo utils.pro 1>&2 sed 's/^-//' >utils.pro <<'End of utils.pro' -void addvars(table vars); -void setiparm(char *s,long v,int isint); -void setparm(char *s,char *t,int ex,int isint); -void unsetparm(char *s); -long getiparm(char *s); -char *getparm(char *s); -void parsepath(void); -void parsecdpath(void); -int source(char *s); -void sourcehome(char *s); -void zerrnam(char *cmd, char *fmt, ...); -void zerr(char *fmt,...); -void niceputc(int c,FILE *f); -void intr(void); -void noholdintr(void); -void holdintr(void); -char *fgetline(char *buf,int len,FILE *in); -char *findcwd(char *s); -char *xsymlink(char *s); -char **slashsplit(char *s); -int islink(char *s); -int xsymlinks(char *s); -void printdir(char *s); -int ddifftime(time_t t1,time_t t2); -void scanjobs(void); -void preprompt(void); -void checkmail(void); -void checkfirstmail(void); -void checkmailpath(void); -void createchtab(void); -void freechnode(void *a); -void freestr(void *a); -void freeanode(void *a); -void freeredir(void *a); -void freeshfunc(void *a); -void freepm(void *a); -void restoretty(void); -void gettyinfo(struct ttyinfo *ti); -void settyinfo(struct ttyinfo *ti); -int zyztem(char *s,char *t); -int waitfork(void); -int movefd(int fd); -void redup(int x,int y); -void settrap(char *s,int empty); -void unsettrap(char *s); -void dotrap(int sig); -char *gettext(comm comm); -char *getltext(list l); -char *getl2text(list2 l); -char *getptext(pline p); -char *getsimptext(comm comm); -char *getfortext(struct fornode *n,comm comm); -char *getwhiletext(struct whilenode *n); -char *getrepeattext(struct repeatnode *n); -char *getiftext(struct ifnode *n); -char *getcasetext(struct casenode *n,table l); -void strucpy(char **s,char *t); -void checkrmall(void); -int getquery(void); -void spscan(char *s,char *junk); -void spckcmd(char **s); -void addlocal(char *s); -void pathsub(char **s); -int strftime(char *buf,int bufsize,char *fmt,struct tm *tm); End of utils.pro echo vars.c 1>&2 sed 's/^-//' >vars.c <<'End of vars.c' -/* - - vars.c - variable declarations - - This file is part of zsh, the Z shell. - - zsh is free software; no one can prevent you from reading the source - code, or giving it to someone else. - This file is copyrighted under the GNU General Public License, which - can be found in the file called COPYING. - - Copyright (C) 1990 Paul Falstad - - zsh is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY. No author or distributor accepts - responsibility to anyone for the consequences of using it or for - whether it serves any particular purpose or works at all, unless he - says so in writing. Refer to the GNU General Public License - for full details. - - Everyone is granted permission to copy, modify and redistribute - zsh, but only under the conditions described in the GNU General Public - License. A copy of this license is supposed to have been given to you - along with zsh so you can know your rights and responsibilities. - It should be in a file named COPYING. - - Among other things, the copyright notice and this notice must be - preserved on all copies. - -*/ - -#include "zsh.h" - -/* buffered shell input for non-interactive shells */ - -FILE *bshin; - -/* null-terminated array of pointers to strings containing elements - of PATH and CDPATH */ - -char **path,**cdpath; - -/* number of elements in aforementioned array */ - -int pathct,cdpathct; - -/* error/break flag */ - -int errflag = 0; - -/* current history event number */ - -int cev = 0; - -/* if != 0, this is the first line of the command */ - -int firstln; - -/* if != 0, this is the first char of the command (not including - white space */ - -int firstch; - -/* first event number in the history table */ - -int tfev = 1; - -/* capacity of history table */ - -int tevs = 20; - -/* if = 1, we have performed history substitution on the current line - if = 2, we have used the 'p' modifier */ - -int hflag; - -/* default event (usually cev-1, that is, "!!") */ - -int dev = 0; - -/* != 0 if we are in the middle of parsing a command (== 0 if we - have not yet parsed the command word */ - -int incmd = 0; - -/* the list of history events */ - -table histlist; - -/* the current history event (can be NULL) */ - -table curtab; - -/* the directory stack */ - -table dirstack; - -/* a string containing all the ungot characters (hungetch()) */ - -char *ungots; - -/* the pointer to the next character to read from ungots */ - -char *ungotptr; - -/* the contents of the IFS parameter */ - -char *ifs; - -/* != 0 if this is a subshell */ - -int subsh; - -/* # of break levels (break builtin) */ - -int breaks; - -/* != 0 if we have a return pending (return builtin) */ - -int retflag; - -/* # of nested loops we are in */ - -int loops; - -/* # of continue levels */ - -int contflag; - -/* the job currently being created/waited for (not current job in the sense - of '+' and '-', that's topjob */ - -int curjob; - -/* the current job (+) */ - -int topjob = -1; - -/* the previous job (-) */ - -int prevjob = -1; - -/* hash table containing the aliases and reserved words */ - -htable alhtab; - -/* hash table containing the parameters */ - -htable parmhtab; - -/* hash table containing the builtins/hashed commands */ - -htable chtab; - -/* hash table containing the shell functions */ - -htable shfunchtab; - -/* the job table */ - -struct jobnode jobtab[MAXJOB]; - -/* the list of sched jobs pending */ - -struct schnode *scheds = NULL; - -/* the last l for s/l/r/ history substitution */ - -char *last; - -/* the last r for s/l/r/ history substitution */ - -char *rast; - -/* if peek == STRING or ENVSTRING, the next token */ - -char *tstr; - -/* who am i */ - -char *username; - -/* the return code of the last command */ - -int lastval; - -/* != 0 if this is a login shell */ - -int islogin; - -/* the next token (enum xtok) */ - -int peek; - -/* the file descriptor associated with the next token, if it - is something like '<' or '>>', etc. */ - -int peekfd; - -/* input fd from the coprocess */ - -int spin = -1; - -/* output fd from the coprocess */ - -int spout = -1; - -/* the last time we checked mail */ - -time_t lastmailcheck; - -/* the last modified date on the mail file last time we checked */ - -time_t lastmailval; - -/* the last time we checked the people in the WATCH variable */ - -time_t lastwatch; - -/* the last time we did the periodic() shell function */ - -time_t lastperiod; - -/* $SECONDS = time(NULL) - shtimer */ - -time_t shtimer; - -/* the size of the mail file last time we checked */ - -off_t lastmailsize; - -/* $$ */ - -long procnum; - -/* $! (the pid of the last background command invoked */ - -long proclast; - -/* the process group of the shell */ - -long shpgrp; - -/* the current working directory */ - -char *cwd; - -/* the hostname, truncated after the '.' */ - -char *hostM; - -/* the hostname */ - -char *hostm; - -/* the home directory */ - -char *home; - -/* the positional parameters */ - -table pparms; - -/* the list of local variables we have to destroy */ - -table locallist; - -/* the shell input fd */ - -int SHIN; - -/* the shell tty fd */ - -int SHTTY; - -/* the stack of aliases we are expanding */ - -struct anode *alstack[MAXAL]; - -/* the alias stack pointer; also, the number of aliases currently - being expanded */ - -int alix = 0; - -/* != 0 means we are reading input from a string */ - -int strin = 0; - -/* == 1 means we are doing TAB expansion - == 2 means expansion has occurred during TAB expansion */ - -int magic = 0; - -/* period between periodic() commands, in seconds */ - -int period = 0; - -/* != 0 means history is turned off (through !" or setopt nobanghist) */ - -int stophist = 0; - -/* != 0 means we have removed the current event from the history list */ - -int histremmed = 0; - -/* the options; e.g. if opts['a'] is nonzero, -a is turned on */ - -int opts[128]; - -/* LINENO */ - -int lineno; - -/* != 0 means we have called execlist() and then intend to exit(), - so don't fork if not necessary */ - -int exiting = 0; - -/* the limits for child processes */ - -struct rlimit limits[RLIM_NLIMITS]; - -/* the tokens */ - -char *tokens = "#$^*()$=|{}[]`<>?~`,"; - -/* the current word in the history list */ - -char *hlastw; - -/* the pointer to the current character in the current word - in the history list */ - -char *hlastp; - -/* the size of the current word in the history list */ - -int hlastsz; - -/* the alias expansion status - if == ALSTAT_MORE, we just finished - expanding an alias ending with a space */ - -int alstat; - -/* we have printed a 'you have stopped (running) jobs.' message */ - -int stopmsg; - -/* the default tty state */ - -struct ttyinfo shttyinfo; - -/* signal names */ - -char *sigs[] = { "EXIT", - "HUP", "INT", "QUIT", "ILL", "TRAP", "IOT", "EMT", "FPE", "KILL", - "BUS", "SEGV", "SYS", "PIPE", "ALRM", "TERM", "URG", "STOP", "TSTP", - "CONT", "CHLD", "TTIN", "TTOU", "IO", "XCPU", "XFSZ", "VTALRM", "PROF", - "WINCH", "LOST", "USR1", "USR2", "ERR", "DEBUG" -}; - -/* signals that are trapped = 1, signals ignored =2 */ - -int sigtrapped[SIGCOUNT+2]; - End of vars.c echo vars.pro 1>&2 sed 's/^-//' >vars.pro <<'End of vars.pro' End of vars.pro echo zhistory.c 1>&2 sed 's/^-//' >zhistory.c <<'End of zhistory.c' -/* - - zhistory.c - interface between readline an zsh's ideas of history - - This file is part of zsh, the Z shell. - - zsh is free software; no one can prevent you from reading the source - code, or giving it to someone else. - This file is copyrighted under the GNU General Public License, which - can be found in the file called COPYING. - - Copyright (C) 1990 Paul Falstad - - zsh is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY. No author or distributor accepts - responsibility to anyone for the consequences of using it or for - whether it serves any particular purpose or works at all, unless he - says so in writing. Refer to the GNU General Public License - for full details. - - Everyone is granted permission to copy, modify and redistribute - zsh, but only under the conditions described in the GNU General Public - License. A copy of this license is supposed to have been given to you - along with zsh so you can know your rights and responsibilities. - It should be in a file named COPYING. - - Among other things, the copyright notice and this notice must be - preserved on all copies. - -*/ - -#include "zsh.h" -#include "funcs.h" -#include "readline/history.h" - -/* bindings to make zsh and readline get along */ - -static int histline; - -void using_history(void) -{ - histline = cev; -} - -int where_history(void) -{ - return histline; -} - -int history_set_pos(int pos) -{ - histline = pos; - return 0; -} - -HIST_ENTRY *current_history(void) -{ -table tab; -char *str; -HIST_ENTRY *he; - - tab = quietgetevent(histline); - if (!tab) - return NULL; - str = makehlist(tab,0); - he = (HIST_ENTRY *) malloc(sizeof *he); - he->line = str; - he->data = NULL; - return he; -} - -HIST_ENTRY *previous_history(void) -{ - if (histline == tfev) - return NULL; - histline--; - return current_history(); -} - -HIST_ENTRY *next_history(void) -{ - if (histline == cev) - return NULL; - histline++; - return current_history(); -} - -char *extracthistarg(int num) -{ -Node n; - - if (histlist->last == (Node) histlist || - histlist->last->last == (Node) histlist) - return NULL; - n = ((table) (histlist->last->last))->first; - for (; n && num; num--,n = n->next); - if (!n) - return NULL; - return strdup(n->dat); -} - End of zhistory.c echo readline/chardefs.h 1>&2 sed 's/^-//' >readline/chardefs.h <<'End of readline/chardefs.h' -/* chardefs.h -- Character definitions for readline. */ -#ifndef _CHARDEFS_ - -#ifndef savestring -#define savestring(x) (char *)strcpy (xmalloc (1 + strlen (x)), (x)) -#endif - -#ifndef whitespace -#define whitespace(c) (((c) == ' ') || ((c) == '\t')) -#endif - -#ifdef CTRL -#undef CTRL -#endif - -/* Some character stuff. */ -#define control_character_threshold 0x020 /* smaller than this is control */ -#define meta_character_threshold 0x07f /* larger than this is Meta. */ -#define control_character_bit 0x40 /* 0x000000, must be off. */ -#define meta_character_bit 0x080 /* x0000000, must be on. */ - -#define CTRL(c) ((c) & (~control_character_bit)) -#define META(c) ((c) | meta_character_bit) - -#define UNMETA(c) ((c) & (~meta_character_bit)) -#define UNCTRL(c) to_upper(((c)|control_character_bit)) - -#define lowercase_p(c) (((c) > ('a' - 1) && (c) < ('z' + 1))) -#define uppercase_p(c) (((c) > ('A' - 1) && (c) < ('Z' + 1))) - -#define pure_alphabetic(c) (lowercase_p(c) || uppercase_p(c)) - -#ifndef to_upper -#define to_upper(c) (lowercase_p(c) ? ((c) - 32) : (c)) -#define to_lower(c) (uppercase_p(c) ? ((c) + 32) : (c)) -#endif - -#define CTRL_P(c) ((c) < control_character_threshold) -#define META_P(c) ((c) > meta_character_threshold) - -#define NEWLINE '\n' -#define RETURN CTRL('M') -#define RUBOUT 0x07f -#define TAB '\t' -#define ABORT_CHAR CTRL('G') -#define PAGE CTRL('L') -#define SPACE 0x020 -#define ESC CTRL('[') - -#endif /* _CHARDEFS_ */ End of readline/chardefs.h echo readline/emacs_keymap.c 1>&2 sed 's/^-//' >readline/emacs_keymap.c <<'End of readline/emacs_keymap.c' -/* emacs_keymap.c -- the keymap for emacs_mode in readline (). */ - -/* Copyright (C) 1988,1989 Free Software Foundation, Inc. - - This file is part of GNU Readline, a library for reading lines - of text with interactive input and history editing. - - Readline is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 1, or (at your option) any - later version. - - Readline is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Readline; see the file COPYING. If not, write to the Free - Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef FILE -#include -#endif /* FILE */ - -#include "readline.h" - -/* An array of function pointers, one for each possible key. - If the type byte is ISKMAP, then the pointer is the address of - a keymap. */ - -KEYMAP_ENTRY_ARRAY emacs_standard_keymap = { - - /* Control keys. */ - { ISFUNC, (Function *)0x0 }, /* Control-@ */ - { ISFUNC, rl_beg_of_line }, /* Control-a */ - { ISFUNC, rl_backward }, /* Control-b */ - { ISFUNC, (Function *)0x0 }, /* Control-c */ - { ISFUNC, rl_delete }, /* Control-d */ - { ISFUNC, rl_end_of_line }, /* Control-e */ - { ISFUNC, rl_forward }, /* Control-f */ - { ISFUNC, rl_abort }, /* Control-g */ - { ISFUNC, rl_rubout }, /* Control-h */ /* pjf */ - { ISFUNC, rl_complete }, /* Control-i */ - { ISFUNC, rl_newline }, /* Control-j */ - { ISFUNC, rl_kill_line }, /* Control-k */ - { ISFUNC, rl_clear_screen }, /* Control-l */ - { ISFUNC, rl_newline }, /* Control-m */ - { ISFUNC, rl_get_next_history }, /* Control-n */ - { ISFUNC, (Function *)0x0 }, /* Control-o */ - { ISFUNC, rl_get_previous_history }, /* Control-p */ - { ISFUNC, rl_quoted_insert }, /* Control-q */ - { ISFUNC, (Function *)0x0 }, /* Control-r */ - { ISFUNC, (Function *)0x0 }, /* Control-s */ - { ISFUNC, rl_transpose_chars }, /* Control-t */ - { ISFUNC, rl_unix_line_discard }, /* Control-u */ - { ISFUNC, rl_quoted_insert }, /* Control-v */ - { ISFUNC, rl_unix_word_rubout }, /* Control-w */ - { ISKMAP, (Function *)emacs_ctlx_keymap }, /* Control-x */ - { ISFUNC, rl_yank }, /* Control-y */ - { ISFUNC, (Function *)0x0 }, /* Control-z */ - { ISKMAP, (Function *)emacs_meta_keymap }, /* Control-[ */ - { ISFUNC, (Function *)0x0 }, /* Control-\ */ - { ISFUNC, (Function *)0x0 }, /* Control-] */ - { ISFUNC, (Function *)0x0 }, /* Control-^ */ - { ISFUNC, rl_undo_command }, /* Control-_ */ - - /* The start of printing characters. */ - { ISFUNC, rl_insert }, /* SPACE */ - { ISFUNC, rl_insert }, /* ! */ - { ISFUNC, rl_insert }, /* " */ - { ISFUNC, rl_insert }, /* # */ - { ISFUNC, rl_insert }, /* $ */ - { ISFUNC, rl_insert }, /* % */ - { ISFUNC, rl_insert }, /* & */ - { ISFUNC, rl_insert }, /* ' */ - { ISFUNC, rl_insert }, /* ( */ - { ISFUNC, rl_insert }, /* ) */ - { ISFUNC, rl_insert }, /* * */ - { ISFUNC, rl_insert }, /* + */ - { ISFUNC, rl_insert }, /* , */ - { ISFUNC, rl_insert }, /* - */ - { ISFUNC, rl_insert }, /* . */ - { ISFUNC, rl_insert }, /* / */ - - /* Regular digits. */ - { ISFUNC, rl_insert }, /* 0 */ - { ISFUNC, rl_insert }, /* 1 */ - { ISFUNC, rl_insert }, /* 2 */ - { ISFUNC, rl_insert }, /* 3 */ - { ISFUNC, rl_insert }, /* 4 */ - { ISFUNC, rl_insert }, /* 5 */ - { ISFUNC, rl_insert }, /* 6 */ - { ISFUNC, rl_insert }, /* 7 */ - { ISFUNC, rl_insert }, /* 8 */ - { ISFUNC, rl_insert }, /* 9 */ - - /* A little more punctuation. */ - { ISFUNC, rl_insert }, /* : */ - { ISFUNC, rl_insert }, /* ; */ - { ISFUNC, rl_insert }, /* < */ - { ISFUNC, rl_insert }, /* = */ - { ISFUNC, rl_insert }, /* > */ - { ISFUNC, rl_insert }, /* ? */ - { ISFUNC, rl_insert }, /* @ */ - - /* Uppercase alphabet. */ - { ISFUNC, rl_insert }, /* A */ - { ISFUNC, rl_insert }, /* B */ - { ISFUNC, rl_insert }, /* C */ - { ISFUNC, rl_insert }, /* D */ - { ISFUNC, rl_insert }, /* E */ - { ISFUNC, rl_insert }, /* F */ - { ISFUNC, rl_insert }, /* G */ - { ISFUNC, rl_insert }, /* H */ - { ISFUNC, rl_insert }, /* I */ - { ISFUNC, rl_insert }, /* J */ - { ISFUNC, rl_insert }, /* K */ - { ISFUNC, rl_insert }, /* L */ - { ISFUNC, rl_insert }, /* M */ - { ISFUNC, rl_insert }, /* N */ - { ISFUNC, rl_insert }, /* O */ - { ISFUNC, rl_insert }, /* P */ - { ISFUNC, rl_insert }, /* Q */ - { ISFUNC, rl_insert }, /* R */ - { ISFUNC, rl_insert }, /* S */ - { ISFUNC, rl_insert }, /* T */ - { ISFUNC, rl_insert }, /* U */ - { ISFUNC, rl_insert }, /* V */ - { ISFUNC, rl_insert }, /* W */ - { ISFUNC, rl_insert }, /* X */ - { ISFUNC, rl_insert }, /* Y */ - { ISFUNC, rl_insert }, /* Z */ - - /* Some more punctuation. */ - { ISFUNC, rl_insert }, /* [ */ - { ISFUNC, rl_insert }, /* \ */ - { ISFUNC, rl_insert }, /* ] */ - { ISFUNC, rl_insert }, /* ^ */ - { ISFUNC, rl_insert }, /* _ */ - { ISFUNC, rl_insert }, /* ` */ - - /* Lowercase alphabet. */ - { ISFUNC, rl_insert }, /* a */ - { ISFUNC, rl_insert }, /* b */ - { ISFUNC, rl_insert }, /* c */ - { ISFUNC, rl_insert }, /* d */ - { ISFUNC, rl_insert }, /* e */ - { ISFUNC, rl_insert }, /* f */ - { ISFUNC, rl_insert }, /* g */ - { ISFUNC, rl_insert }, /* h */ - { ISFUNC, rl_insert }, /* i */ - { ISFUNC, rl_insert }, /* j */ - { ISFUNC, rl_insert }, /* k */ - { ISFUNC, rl_insert }, /* l */ - { ISFUNC, rl_insert }, /* m */ - { ISFUNC, rl_insert }, /* n */ - { ISFUNC, rl_insert }, /* o */ - { ISFUNC, rl_insert }, /* p */ - { ISFUNC, rl_insert }, /* q */ - { ISFUNC, rl_insert }, /* r */ - { ISFUNC, rl_insert }, /* s */ - { ISFUNC, rl_insert }, /* t */ - { ISFUNC, rl_insert }, /* u */ - { ISFUNC, rl_insert }, /* v */ - { ISFUNC, rl_insert }, /* w */ - { ISFUNC, rl_insert }, /* x */ - { ISFUNC, rl_insert }, /* y */ - { ISFUNC, rl_insert }, /* z */ - - /* Final punctuation. */ - { ISFUNC, rl_insert }, /* { */ - { ISFUNC, rl_insert }, /* | */ - { ISFUNC, rl_insert }, /* } */ - { ISFUNC, rl_insert }, /* ~ */ - { ISFUNC, rl_rubout } /* RUBOUT */ -}; - -KEYMAP_ENTRY_ARRAY emacs_meta_keymap = { - - /* Meta keys. Just like above, but the high bit is set. */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-@ */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-a */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-b */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-c */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-d */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-e */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-f */ - { ISFUNC, rl_abort }, /* Meta-Control-g */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-h */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-i */ - { ISFUNC, rl_vi_editing_mode }, /* Meta-Control-j */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-k */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-l */ - { ISFUNC, rl_vi_editing_mode }, /* Meta-Control-m */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-n */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-o */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-p */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-q */ - { ISFUNC, rl_revert_line }, /* Meta-Control-r */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-s */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-t */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-u */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-v */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-w */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-x */ - { ISFUNC, rl_yank_nth_arg }, /* Meta-Control-y */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-z */ - - { ISFUNC, (Function *)0x0 }, /* Meta-Control-[ */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-\ */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-] */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-^ */ - { ISFUNC, (Function *)0x0 }, /* Meta-Control-_ */ - - /* The start of printing characters. */ - { ISFUNC, (Function *)rl_magic_space }, /* Meta-SPACE */ - { ISFUNC, (Function *)0x0 }, /* Meta-! */ - { ISFUNC, (Function *)0x0 }, /* Meta-" */ - { ISFUNC, (Function *)0x0 }, /* Meta-# */ - { ISFUNC, rl_check_spelling }, /* Meta-$ */ - { ISFUNC, (Function *)0x0 }, /* Meta-% */ - { ISFUNC, (Function *)0x0 }, /* Meta-& */ - { ISFUNC, (Function *)0x0 }, /* Meta-' */ - { ISFUNC, (Function *)0x0 }, /* Meta-( */ - { ISFUNC, (Function *)0x0 }, /* Meta-) */ - { ISFUNC, (Function *)0x0 }, /* Meta-* */ - { ISFUNC, (Function *)0x0 }, /* Meta-+ */ - { ISFUNC, (Function *)0x0 }, /* Meta-, */ - { ISFUNC, rl_digit_argument }, /* Meta-- */ - { ISFUNC, (Function *)0x0 }, /* Meta-. */ - { ISFUNC, (Function *)0x0 }, /* Meta-/ */ - - /* Regular digits. */ - { ISFUNC, rl_digit_argument }, /* Meta-0 */ - { ISFUNC, rl_digit_argument }, /* Meta-1 */ - { ISFUNC, rl_digit_argument }, /* Meta-2 */ - { ISFUNC, rl_digit_argument }, /* Meta-3 */ - { ISFUNC, rl_digit_argument }, /* Meta-4 */ - { ISFUNC, rl_digit_argument }, /* Meta-5 */ - { ISFUNC, rl_digit_argument }, /* Meta-6 */ - { ISFUNC, rl_digit_argument }, /* Meta-7 */ - { ISFUNC, rl_digit_argument }, /* Meta-8 */ - { ISFUNC, rl_digit_argument }, /* Meta-9 */ - - /* A little more punctuation. */ - { ISFUNC, (Function *)0x0 }, /* Meta-: */ - { ISFUNC, (Function *)0x0 }, /* Meta-; */ - { ISFUNC, rl_beginning_of_history }, /* Meta-< */ - { ISFUNC, (Function *)0x0 }, /* Meta-= */ - { ISFUNC, rl_end_of_history }, /* Meta-> */ - { ISFUNC, rl_possible_completions }, /* Meta-? */ - { ISFUNC, (Function *)0x0 }, /* Meta-@ */ - - /* Uppercase alphabet. */ - { ISFUNC, rl_do_lowercase_version }, /* Meta-A */ - { ISFUNC, rl_do_lowercase_version }, /* Meta-B */ - { ISFUNC, rl_do_lowercase_version }, /* Meta-C */ - { ISFUNC, rl_do_lowercase_version }, /* Meta-D */ - { ISFUNC, rl_do_lowercase_version }, /* Meta-E */ - { ISFUNC, rl_do_lowercase_version }, /* Meta-F */ - { ISFUNC, rl_do_lowercase_version }, /* Meta-G */ - { ISFUNC, rl_do_lowercase_version }, /* Meta-H */ - { ISFUNC, rl_do_lowercase_version }, /* Meta-I */ - { ISFUNC, rl_do_lowercase_version }, /* Meta-J */ - { ISFUNC, rl_do_lowercase_version }, /* Meta-K */ - { ISFUNC, rl_do_lowercase_version }, /* Meta-L */ - { ISFUNC, rl_do_lowercase_version }, /* Meta-M */ - { ISFUNC, rl_do_lowercase_version }, /* Meta-N */ - { ISFUNC, rl_do_lowercase_version }, /* Meta-O */ - { ISFUNC, rl_do_lowercase_version }, /* Meta-P */ - { ISFUNC, rl_do_lowercase_version }, /* Meta-Q */ - { ISFUNC, rl_do_lowercase_version }, /* Meta-R */ - { ISFUNC, rl_do_lowercase_version }, /* Meta-S */ - { ISFUNC, rl_do_lowercase_version }, /* Meta-T */ - { ISFUNC, rl_do_lowercase_version }, /* Meta-U */ - { ISFUNC, rl_do_lowercase_version }, /* Meta-V */ - { ISFUNC, rl_do_lowercase_version }, /* Meta-W */ - { ISFUNC, rl_do_lowercase_version }, /* Meta-X */ - { ISFUNC, rl_do_lowercase_version }, /* Meta-Y */ - { ISFUNC, rl_do_lowercase_version }, /* Meta-Z */ - - /* Some more punctuation. */ - { ISFUNC, rl_function_key }, /* Meta-[ */ - { ISFUNC, (Function *)0x0 }, /* Meta-\ */ - { ISFUNC, (Function *)0x0 }, /* Meta-] */ - { ISFUNC, (Function *)0x0 }, /* Meta-^ */ - { ISFUNC, (Function *)0x0 }, /* Meta-_ */ - { ISFUNC, (Function *)0x0 }, /* Meta-` */ - - /* Lowercase alphabet. */ - { ISFUNC, (Function *)0x0 }, /* Meta-a */ - { ISFUNC, rl_backward_word }, /* Meta-b */ - { ISFUNC, rl_capitalize_word }, /* Meta-c */ - { ISFUNC, rl_kill_word }, /* Meta-d */ - { ISFUNC, (Function *)0x0 }, /* Meta-e */ - { ISFUNC, rl_forward_word }, /* Meta-f */ - { ISFUNC, (Function *)0x0 }, /* Meta-g */ - { ISFUNC, (Function *)0x0 }, /* Meta-h */ - { ISFUNC, (Function *)0x0 }, /* Meta-i */ - { ISFUNC, (Function *)0x0 }, /* Meta-j */ - { ISFUNC, (Function *)0x0 }, /* Meta-k */ - { ISFUNC, rl_downcase_word }, /* Meta-l */ - { ISFUNC, (Function *)0x0 }, /* Meta-m */ - { ISFUNC, (Function *)0x0 }, /* Meta-n */ - { ISFUNC, (Function *)0x0 }, /* Meta-o */ - { ISFUNC, (Function *)0x0 }, /* Meta-p */ - { ISFUNC, (Function *)0x0 }, /* Meta-q */ - { ISFUNC, rl_revert_line }, /* Meta-r */ - { ISFUNC, (Function *)0x0 }, /* Meta-s */ - { ISFUNC, rl_transpose_words }, /* Meta-t */ - { ISFUNC, rl_upcase_word }, /* Meta-u */ - { ISFUNC, (Function *)0x0 }, /* Meta-v */ - { ISFUNC, (Function *)0x0 }, /* Meta-w */ - { ISFUNC, (Function *)0x0 }, /* Meta-x */ - { ISFUNC, rl_yank_pop }, /* Meta-y */ - { ISFUNC, (Function *)0x0 }, /* Meta-z */ - - /* Final punctuation. */ - { ISFUNC, (Function *)0x0 }, /* Meta-{ */ - { ISFUNC, (Function *)0x0 }, /* Meta-| */ - { ISFUNC, (Function *)0x0 }, /* Meta-} */ - { ISFUNC, (Function *)0x0 }, /* Meta-~ */ - { ISFUNC, rl_backward_kill_word } /* Meta-rubout */ -}; - -KEYMAP_ENTRY_ARRAY emacs_ctlx_keymap = { - - /* Control keys. */ - { ISFUNC, (Function *)0x0 }, /* Control-@ */ - { ISFUNC, (Function *)0x0 }, /* Control-a */ - { ISFUNC, (Function *)0x0 }, /* Control-b */ - { ISFUNC, (Function *)0x0 }, /* Control-c */ - { ISFUNC, (Function *)0x0 }, /* Control-d */ - { ISFUNC, (Function *)0x0 }, /* Control-e */ - { ISFUNC, (Function *)0x0 }, /* Control-f */ - { ISFUNC, rl_abort }, /* Control-g */ - { ISFUNC, (Function *)0x0 }, /* Control-h */ - { ISFUNC, (Function *)0x0 }, /* Control-i */ - { ISFUNC, (Function *)0x0 }, /* Control-j */ - { ISFUNC, (Function *)0x0 }, /* Control-k */ - { ISFUNC, (Function *)0x0 }, /* Control-l */ - { ISFUNC, (Function *)0x0 }, /* Control-m */ - { ISFUNC, (Function *)0x0 }, /* Control-n */ - { ISFUNC, (Function *)0x0 }, /* Control-o */ - { ISFUNC, (Function *)0x0 }, /* Control-p */ - { ISFUNC, (Function *)0x0 }, /* Control-q */ - { ISFUNC, rl_re_read_init_file }, /* Control-r */ - { ISFUNC, (Function *)0x0 }, /* Control-s */ - { ISFUNC, (Function *)0x0 }, /* Control-t */ - { ISFUNC, rl_undo_command }, /* Control-u */ - { ISFUNC, (Function *)0x0 }, /* Control-v */ - { ISFUNC, (Function *)0x0 }, /* Control-w */ - { ISFUNC, (Function *)0x0 }, /* Control-x */ - { ISFUNC, (Function *)0x0 }, /* Control-y */ - { ISFUNC, (Function *)0x0 }, /* Control-z */ - { ISFUNC, (Function *)0x0 }, /* Control-[ */ - { ISFUNC, (Function *)0x0 }, /* Control-\ */ - { ISFUNC, (Function *)0x0 }, /* Control-] */ - { ISFUNC, (Function *)0x0 }, /* Control-^ */ - { ISFUNC, (Function *)0x0 }, /* Control-_ */ - - /* The start of printing characters. */ - { ISFUNC, (Function *)0x0 }, /* SPACE */ - { ISFUNC, (Function *)0x0 }, /* ! */ - { ISFUNC, (Function *)0x0 }, /* " */ - { ISFUNC, (Function *)0x0 }, /* # */ - { ISFUNC, (Function *)0x0 }, /* $ */ - { ISFUNC, (Function *)0x0 }, /* % */ - { ISFUNC, (Function *)0x0 }, /* & */ - { ISFUNC, (Function *)0x0 }, /* ' */ - { ISFUNC, rl_start_kbd_macro }, /* ( */ - { ISFUNC, rl_end_kbd_macro }, /* ) */ - { ISFUNC, (Function *)0x0 }, /* * */ - { ISFUNC, (Function *)0x0 }, /* + */ - { ISFUNC, (Function *)0x0 }, /* , */ - { ISFUNC, (Function *)0x0 }, /* - */ - { ISFUNC, (Function *)0x0 }, /* . */ - { ISFUNC, (Function *)0x0 }, /* / */ - - /* Regular digits. */ - { ISFUNC, (Function *)0x0 }, /* 0 */ - { ISFUNC, (Function *)0x0 }, /* 1 */ - { ISFUNC, (Function *)0x0 }, /* 2 */ - { ISFUNC, (Function *)0x0 }, /* 3 */ - { ISFUNC, (Function *)0x0 }, /* 4 */ - { ISFUNC, (Function *)0x0 }, /* 5 */ - { ISFUNC, (Function *)0x0 }, /* 6 */ - { ISFUNC, (Function *)0x0 }, /* 7 */ - { ISFUNC, (Function *)0x0 }, /* 8 */ - { ISFUNC, (Function *)0x0 }, /* 9 */ - - /* A little more punctuation. */ - { ISFUNC, (Function *)0x0 }, /* : */ - { ISFUNC, (Function *)0x0 }, /* ; */ - { ISFUNC, (Function *)0x0 }, /* < */ - { ISFUNC, (Function *)0x0 }, /* = */ - { ISFUNC, (Function *)0x0 }, /* > */ - { ISFUNC, (Function *)0x0 }, /* ? */ - { ISFUNC, (Function *)0x0 }, /* @ */ - - /* Uppercase alphabet. */ - { ISFUNC, rl_do_lowercase_version }, /* A */ - { ISFUNC, rl_do_lowercase_version }, /* B */ - { ISFUNC, rl_do_lowercase_version }, /* C */ - { ISFUNC, rl_do_lowercase_version }, /* D */ - { ISFUNC, rl_do_lowercase_version }, /* E */ - { ISFUNC, rl_do_lowercase_version }, /* F */ - { ISFUNC, rl_do_lowercase_version }, /* G */ - { ISFUNC, rl_do_lowercase_version }, /* H */ - { ISFUNC, rl_do_lowercase_version }, /* I */ - { ISFUNC, rl_do_lowercase_version }, /* J */ - { ISFUNC, rl_do_lowercase_version }, /* K */ - { ISFUNC, rl_do_lowercase_version }, /* L */ - { ISFUNC, rl_do_lowercase_version }, /* M */ - { ISFUNC, rl_do_lowercase_version }, /* N */ - { ISFUNC, rl_do_lowercase_version }, /* O */ - { ISFUNC, rl_do_lowercase_version }, /* P */ - { ISFUNC, rl_do_lowercase_version }, /* Q */ - { ISFUNC, rl_do_lowercase_version }, /* R */ - { ISFUNC, rl_do_lowercase_version }, /* S */ - { ISFUNC, rl_do_lowercase_version }, /* T */ - { ISFUNC, rl_do_lowercase_version }, /* U */ - { ISFUNC, rl_do_lowercase_version }, /* V */ - { ISFUNC, rl_do_lowercase_version }, /* W */ - { ISFUNC, rl_do_lowercase_version }, /* X */ - { ISFUNC, rl_do_lowercase_version }, /* Y */ - { ISFUNC, rl_do_lowercase_version }, /* Z */ - - /* Some more punctuation. */ - { ISFUNC, (Function *)0x0 }, /* [ */ - { ISFUNC, (Function *)0x0 }, /* \ */ - { ISFUNC, (Function *)0x0 }, /* ] */ - { ISFUNC, (Function *)0x0 }, /* ^ */ - { ISFUNC, (Function *)0x0 }, /* _ */ - { ISFUNC, (Function *)0x0 }, /* ` */ - - /* Lowercase alphabet. */ - { ISFUNC, (Function *)0x0 }, /* a */ - { ISFUNC, (Function *)0x0 }, /* b */ - { ISFUNC, (Function *)0x0 }, /* c */ - { ISFUNC, (Function *)0x0 }, /* d */ - { ISFUNC, rl_call_last_kbd_macro }, /* e */ - { ISFUNC, (Function *)0x0 }, /* f */ - { ISFUNC, (Function *)0x0 }, /* g */ - { ISFUNC, (Function *)0x0 }, /* h */ - { ISFUNC, (Function *)0x0 }, /* i */ - { ISFUNC, (Function *)0x0 }, /* j */ - { ISFUNC, (Function *)0x0 }, /* k */ - { ISFUNC, (Function *)0x0 }, /* l */ - { ISFUNC, (Function *)0x0 }, /* m */ - { ISFUNC, (Function *)0x0 }, /* n */ - { ISFUNC, (Function *)0x0 }, /* o */ - { ISFUNC, (Function *)0x0 }, /* p */ - { ISFUNC, (Function *)0x0 }, /* q */ - { ISFUNC, (Function *)0x0 }, /* r */ - { ISFUNC, (Function *)0x0 }, /* s */ - { ISFUNC, (Function *)0x0 }, /* t */ - { ISFUNC, (Function *)0x0 }, /* u */ - { ISFUNC, (Function *)0x0 }, /* v */ - { ISFUNC, (Function *)0x0 }, /* w */ - { ISFUNC, (Function *)0x0 }, /* x */ - { ISFUNC, (Function *)0x0 }, /* y */ - { ISFUNC, (Function *)0x0 }, /* z */ - - /* Final punctuation. */ - { ISFUNC, (Function *)0x0 }, /* { */ - { ISFUNC, (Function *)0x0 }, /* | */ - { ISFUNC, (Function *)0x0 }, /* } */ - { ISFUNC, (Function *)0x0 }, /* ~ */ - { ISFUNC, rl_backward_kill_line } /* RUBOUT */ -}; End of readline/emacs_keymap.c echo readline/funmap.c 1>&2 sed 's/^-//' >readline/funmap.c <<'End of readline/funmap.c' -/* funmap.c -- attach names to functions. */ - -/* Copyright (C) 1988,1989 Free Software Foundation, Inc. - - This file is part of GNU Readline, a library for reading lines - of text with interactive input and history editing. - - Readline is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 1, or (at your option) any - later version. - - Readline is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Readline; see the file COPYING. If not, write to the Free - Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define STATIC_MALLOC -#ifndef STATIC_MALLOC -extern char *xmalloc (), *xrealloc (); -#else -static char *xmalloc (), *xrealloc (); -#endif - -#ifndef FILE -#include -#endif /* FILE */ - -#include "readline.h" - -FUNMAP **funmap = (FUNMAP **)NULL; -static int funmap_size = 0; -static int funmap_entry = 0; - -static FUNMAP default_funmap[] = { - { "beginning-of-line", rl_beg_of_line }, - { "backward-char", rl_backward }, - { "delete-char", rl_delete }, - { "end-of-line", rl_end_of_line }, - { "forward-char", rl_forward }, - { "accept-line", rl_newline }, - { "kill-line", rl_kill_line }, - { "clear-screen", rl_clear_screen }, - { "next-history", rl_get_next_history }, - { "previous-history", rl_get_previous_history }, - { "quoted-insert", rl_quoted_insert }, - { "transpose-chars", rl_transpose_chars }, - { "unix-line-discard", rl_unix_line_discard }, - { "unix-word-rubout", rl_unix_word_rubout }, - { "yank", rl_yank }, - { "yank-pop", rl_yank_pop }, - { "yank-nth-arg", rl_yank_nth_arg }, - { "backward-delete-char", rl_rubout }, - { "backward-word", rl_backward_word }, - { "kill-word", rl_kill_word }, - { "forward-word", rl_forward_word }, - { "tab-insert", rl_tab_insert }, - { "backward-kill-word", rl_backward_kill_word }, - { "backward-kill-line", rl_backward_kill_line }, - { "transpose-words", rl_transpose_words }, - { "digit-argument", rl_digit_argument }, - { "complete", rl_complete }, - { "possible-completions", rl_possible_completions }, - { "do-lowercase-version", rl_do_lowercase_version }, - { "digit-argument", rl_digit_argument }, - { "universal-argument", rl_universal_argument }, - { "abort", rl_abort }, - { "undo", rl_undo_command }, - { "upcase-word", rl_upcase_word }, - { "downcase-word", rl_downcase_word }, - { "capitalize-word", rl_capitalize_word }, - { "revert-line", rl_revert_line }, - { "beginning-of-history", rl_beginning_of_history }, - { "end-of-history", rl_end_of_history }, - { "self-insert", rl_insert }, - { "start-kbd-macro", rl_start_kbd_macro }, - { "end-kbd-macro", rl_end_kbd_macro }, - { "re-read-init-file", rl_re_read_init_file }, - { "history-expand", rl_magic_space }, - { "check-spelling", rl_check_spelling }, -#ifdef VI_MODE - { "vi-movement-mode", rl_vi_movement_mode }, - { "vi-insertion-mode", rl_vi_insertion_mode }, - { "vi-arg-digit", rl_vi_arg_digit }, - { "vi-prev-word", rl_vi_prev_word }, - { "vi-next-word", rl_vi_next_word }, - { "vi-char-search", rl_vi_char_search }, - { "vi-editing-mode", rl_vi_editing_mode }, - { "vi-eof-maybe", rl_vi_eof_maybe }, - { "vi-append-mode", rl_vi_append_mode }, - { "vi-put", rl_vi_put }, - { "vi-append-eol", rl_vi_append_eol }, - { "vi-insert-beg", rl_vi_insert_beg }, - { "vi-delete", rl_vi_delete }, - { "vi-comment", rl_vi_comment }, - { "vi-first-print", rl_vi_first_print }, - { "vi-fword", rl_vi_fword }, - { "vi-fWord", rl_vi_fWord }, - { "vi-bword", rl_vi_bword }, - { "vi-bWord", rl_vi_bWord }, - { "vi-eword", rl_vi_eword }, - { "vi-eWord", rl_vi_eWord }, - { "vi-end-word", rl_vi_end_word }, - { "vi-change-case", rl_vi_change_case }, - { "vi-match", rl_vi_match }, - { "vi-bracktype", rl_vi_bracktype }, - { "vi-change-char", rl_vi_change_char }, - { "vi-yank-arg", rl_vi_yank_arg }, - { "vi-search", rl_vi_search }, - { "vi-search-again", rl_vi_search_again }, - { "vi-dosearch", rl_vi_dosearch }, - { "vi-subst", rl_vi_subst }, - { "vi-overstrike", rl_vi_overstrike }, - { "vi-overstrike-delete", rl_vi_overstrike_delete }, - { "vi-replace, ", rl_vi_replace }, - { "vi-column", rl_vi_column }, - { "vi-delete-to", rl_vi_delete_to }, - { "vi-change-to", rl_vi_change_to }, - { "vi-yank-to", rl_vi_yank_to }, - { "vi-complete", rl_vi_complete }, -#endif /* VI_MODE */ - - {(char *)NULL, (Function *)NULL } -}; - -rl_add_funmap_entry (name, function) - char *name; - Function *function; -{ - if (funmap_entry + 2 >= funmap_size) - if (!funmap) - funmap = (FUNMAP **)xmalloc ((funmap_size = 80) * sizeof (FUNMAP *)); - else - funmap = - (FUNMAP **)xrealloc (funmap, (funmap_size += 80) * sizeof (FUNMAP *)); - - funmap[funmap_entry] = (FUNMAP *)xmalloc (sizeof (FUNMAP)); - funmap[funmap_entry]->name = name; - funmap[funmap_entry]->function = function; - - funmap[++funmap_entry] = (FUNMAP *)NULL; -} - -static int funmap_initialized = 0; - -/* Make the funmap contain all of the default entries. */ -rl_initialize_funmap () -{ - register int i; - - if (funmap_initialized) - return; - - for (i = 0; default_funmap[i].name; i++) - rl_add_funmap_entry (default_funmap[i].name, default_funmap[i].function); - - funmap_initialized = 1; -} - -/* Things that mean `Control'. */ -char *possible_control_prefixes[] = { - "Control-", "C-", "CTRL-", (char *)NULL -}; - -char *possible_meta_prefixes[] = { - "Meta", "M-", (char *)NULL -}; - -#ifdef STATIC_MALLOC - -/* **************************************************************** */ -/* */ -/* xmalloc and xrealloc () */ -/* */ -/* **************************************************************** */ - -static void memory_error_and_abort (); - -static char * -xmalloc (bytes) - int bytes; -{ - char *temp = (char *)malloc (bytes); - - if (!temp) - memory_error_and_abort (); - return (temp); -} - -static char * -xrealloc (pointer, bytes) - char *pointer; - int bytes; -{ - char *temp = (char *)realloc (pointer, bytes); - - if (!temp) - memory_error_and_abort (); - return (temp); -} - -static void -memory_error_and_abort () -{ - fprintf (stderr, "history: Out of virtual memory!\n"); - abort (); -} -#endif /* STATIC_MALLOC */ End of readline/funmap.c echo readline/history.h 1>&2 sed 's/^-//' >readline/history.h <<'End of readline/history.h' -/* History.h -- the names of functions that you can call in history. */ -/* modified by pjf */ - -typedef struct _hist_entry { - char *line; - char *data; -} HIST_ENTRY; - -/* For convenience only. You set this when interpreting history commands. - It is the logical offset of the first history element. */ -extern int tfev; -#define history_base tfev - -/* Begin a session in which the history functions might be used. This - just initializes the interactive variables. */ -extern void using_history (); - -/* Place STRING at the end of the history list. - The associated data field (if any) is set to NULL. */ -/* extern void add_history (); */ - -/* Returns the number which says what history element we are now - looking at. */ -extern int where_history (); - -/* Set the position in the history list to POS. */ -int history_set_pos (); - -/* Search for STRING in the history list, starting at POS, an - absolute index into the list. DIR, if negative, says to search - backwards from POS, else forwards. - Returns the absolute index of the history element where STRING - was found, or -1 otherwise. */ -extern int history_search_pos (); - -/* A reasonably useless function, only here for completeness. WHICH - is the magic number that tells us which element to delete. The - elements are numbered from 0. */ -/* inline HIST_ENTRY *remove_history () {return NULL;} */ - -/* Stifle the history list, remembering only MAX number of entries. */ -/* extern void stifle_history (); */ - -/* Stop stifling the history. This returns the previous amount the - history was stifled by. The value is positive if the history was - stifled, negative if it wasn't. */ -/* extern int unstifle_history (); */ - -/* Add the contents of FILENAME to the history list, a line at a time. - If FILENAME is NULL, then read from ~/.history. Returns 0 if - successful, or errno if not. */ -/* extern int read_history (); */ - -/* Append the current history to FILENAME. If FILENAME is NULL, - then append the history list to ~/.history. Values returned - are as in read_history (). */ -/* extern int write_history (); */ - - -/* Make the history entry at WHICH have LINE and DATA. This returns - the old entry so you can dispose of the data. In the case of an - invalid WHICH, a NULL pointer is returned. */ -/* extern HIST_ENTRY *replace_history_entry (); */ - -/* Return the history entry at the current position, as determined by - history_offset. If there is no entry there, return a NULL pointer. */ -HIST_ENTRY *current_history (); - -/* Back up history_offset to the previous history entry, and return - a pointer to that entry. If there is no previous entry, return - a NULL pointer. */ -extern HIST_ENTRY *previous_history (); - -/* Move history_offset forward to the next item in the input_history, - and return the a pointer to that entry. If there is no next entry, - return a NULL pointer. */ -extern HIST_ENTRY *next_history (); - -/* Return a NULL terminated array of HIST_ENTRY which is the current input - history. Element 0 of this list is the beginning of time. If there - is no history, return NULL. */ -/*extern HIST_ENTRY **history_list ();*/ - -/* Search the history for STRING, starting at history_offset. - If DIRECTION < 0, then the search is through previous entries, - else through subsequent. If the string is found, then - current_history () is the history entry, and the value of this function - is the offset in the line of that history entry that the string was - found in. Otherwise, nothing is changed, and a -1 is returned. */ -/* extern int history_search (); */ - -/* Expand the string STRING, placing the result into OUTPUT, a pointer - to a string. Returns: - - 0) If no expansions took place (or, if the only change in - the text was the de-slashifying of the history expansion - character) - 1) If expansions did take place - -1) If there was an error in expansion. - - If an error ocurred in expansion, then OUTPUT contains a descriptive - error message. */ -/*extern int history_expand ();*/ - -/* Extract a string segment consisting of the FIRST through LAST - arguments present in STRING. Arguments are broken up as in - the shell. pjf: only 1-segment strings are supported. */ -extern char *history_arg_extract (); - - End of readline/history.h echo readline/keymaps.c 1>&2 sed 's/^-//' >readline/keymaps.c <<'End of readline/keymaps.c' -/* keymaps.c -- Functions and keymaps for the GNU Readline library. */ - -/* Copyright (C) 1988,1989 Free Software Foundation, Inc. - - This file is part of GNU Readline, a library for reading lines - of text with interactive input and history editing. - - Readline is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 1, or (at your option) any - later version. - - Readline is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Readline; see the file COPYING. If not, write to the Free - Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "keymaps.h" -#include "emacs_keymap.c" - -#ifdef VI_MODE -#include "vi_keymap.c" -#endif - -/* Remove these declarations when we have a complete libgnu.a. */ -#define STATIC_MALLOC -#ifndef STATIC_MALLOC -extern char *xmalloc (), *xrealloc (); -#else -static char *xmalloc (), *xrealloc (); -#endif - -/* **************************************************************** */ -/* */ -/* Functions for manipulating Keymaps. */ -/* */ -/* **************************************************************** */ - - -/* Return a new, empty keymap. - Free it with free() when you are done. */ -Keymap -rl_make_bare_keymap () -{ - register int i; - Keymap keymap = (Keymap)xmalloc (128 * sizeof (KEYMAP_ENTRY)); - - for (i = 0; i < 128; i++) - { - keymap[i].type = ISFUNC; - keymap[i].function = (Function *)NULL; - } - - for (i = 'A'; i < ('Z' + 1); i++) - { - keymap[i].type = ISFUNC; - keymap[i].function = rl_do_lowercase_version; - } - - return (keymap); -} - -/* Return a new keymap which is a copy of MAP. */ -Keymap -rl_copy_keymap (map) - Keymap map; -{ - register int i; - Keymap temp = rl_make_bare_keymap (); - - for (i = 0; i < 128; i++) - { - temp[i].type = map[i].type; - temp[i].function = map[i].function; - } - return (temp); -} - -/* Return a new keymap with the printing characters bound to rl_insert, - the uppercase Meta characters bound to run their lowercase equivalents, - and the Meta digits bound to produce numeric arguments. */ -Keymap -rl_make_keymap () -{ - extern rl_insert (), rl_rubout (), rl_do_lowercase_version (); - extern rl_digit_argument (); - register int i; - Keymap newmap; - - newmap = rl_make_bare_keymap (); - - /* All printing characters are self-inserting. */ - for (i = ' '; i < 126; i++) - newmap[i].function = rl_insert; - - newmap[TAB].function = rl_insert; - newmap[RUBOUT].function = rl_rubout; - - return (newmap); -} - -/* Free the storage associated with MAP. */ -rl_discard_keymap (map) - Keymap (map); -{ - int i; - - if (!map) - return; - - for (i = 0; i < 128; i++) - { - switch (map[i].type) - { - case ISFUNC: - break; - - case ISKMAP: - rl_discard_keymap ((Keymap)map[i].function); - break; - - case ISMACR: - free ((char *)map[i].function); - break; - } - } -} - -#ifdef STATIC_MALLOC - -/* **************************************************************** */ -/* */ -/* xmalloc and xrealloc () */ -/* */ -/* **************************************************************** */ - -static void memory_error_and_abort (); - -static char * -xmalloc (bytes) - int bytes; -{ - char *temp = (char *)malloc (bytes); - - if (!temp) - memory_error_and_abort (); - return (temp); -} - -static char * -xrealloc (pointer, bytes) - char *pointer; - int bytes; -{ - char *temp = (char *)realloc (pointer, bytes); - - if (!temp) - memory_error_and_abort (); - return (temp); -} - -static void -memory_error_and_abort () -{ - fprintf (stderr, "readline: Out of virtual memory!\n"); - abort (); -} -#endif /* STATIC_MALLOC */ End of readline/keymaps.c echo readline/keymaps.h 1>&2 sed 's/^-//' >readline/keymaps.h <<'End of readline/keymaps.h' -/* keymaps.h -- Manipulation of readline keymaps. */ - -#ifndef _KEYMAPS_H_ -#define _KEYMAPS_H_ - -#include - -#ifndef __FUNCTION_DEF -typedef int Function (); -#define __FUNCTION_DEF -#endif - -/* A keymap contains one entry for each key in the ASCII set. - Each entry consists of a type and a pointer. - POINTER is the address of a function to run, or the - address of a keymap to indirect through. - TYPE says which kind of thing POINTER is. */ -typedef struct _keymap_entry { - char type; - Function *function; -} KEYMAP_ENTRY; - -/* I wanted to make the above structure contain a union of: - union { Function *function; struct _keymap_entry *keymap; } value; - but this made it impossible for me to create a static array. - Maybe I need C lessons. */ - -typedef KEYMAP_ENTRY KEYMAP_ENTRY_ARRAY[128]; -typedef KEYMAP_ENTRY *Keymap; - -/* The values that TYPE can have in a keymap entry. */ -#define ISFUNC 0 -#define ISKMAP 1 -#define ISMACR 2 - -extern KEYMAP_ENTRY_ARRAY emacs_standard_keymap, emacs_meta_keymap, emacs_ctlx_keymap; -extern KEYMAP_ENTRY_ARRAY vi_insertion_keymap, vi_movement_keymap; - -/* Return a new, empty keymap. - Free it with free() when you are done. */ -Keymap rl_make_bare_keymap (); - -/* Return a new keymap which is a copy of MAP. */ -Keymap rl_copy_keymap (); - -/* Return a new keymap with the printing characters bound to rl_insert, - the lowercase Meta characters bound to run their equivalents, and - the Meta digits bound to produce numeric arguments. */ -Keymap rl_make_keymap (); - -#endif /* _KEYMAPS_H_ */ - - End of readline/keymaps.h echo readline/readline.c 1>&2 sed 's/^-//' >readline/readline.c <<'End of readline/readline.c' -/* readline.c -- a general facility for reading lines of input - with emacs style editing and completion. */ - -/* Copyright (C) 1987,1989 Free Software Foundation, Inc. - - This file contains the Readline Library (the Library), a set of - routines for providing Emacs style line input to programs that ask - for it. - - The Library is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 1, or (at your option) - any later version. - - The Library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Remove these declarations when we have a complete libgnu.a. */ -#define STATIC_MALLOC -#ifndef STATIC_MALLOC -extern char *xmalloc (), *xrealloc (); -#else -static char *xmalloc (), *xrealloc (); -#endif - -char *docompsubs(); -extern int errno,errflag; - -#include -#include -#include -#include -#include -#include - -#ifdef __GNUC__ -#define alloca __builtin_alloca -#else -#if defined (sparc) && defined (sun) -#include -#endif -#endif - -#define NEW_TTY_DRIVER -#if defined (SYSV) || defined (hpux) -#undef NEW_TTY_DRIVER -#include -#else -#include -#endif - -#include -extern int errno; - -#include - -/* These next are for filename completion. Perhaps this belongs - in a different place. */ -#include - -#include -#ifdef SYSV -struct passwd *getpwuid (), *getpwent (); -#endif - -#define HACK_TERMCAP_MOTION - -#ifndef SYSV -#include -#else /* SYSV */ -#if defined (xenix) -#include -#else -#ifdef hpux -#include -#else -#include -#define direct dirent -#define d_namlen d_reclen -#endif /* hpux */ -#endif /* xenix */ -#endif /* SYSV */ - -#ifndef O_CBREAK -#define O_CBREAK CBREAK -#define O_ECHO ECHO -#define O_RAW RAW -#endif - -/* Some standard library routines. */ -#include "readline.h" -#include "history.h" - -#ifndef digit -#define digit(c) ((c) >= '0' && (c) <= '9') -#endif - -#ifndef isletter -#define isletter(c) (((c) >= 'A' && (c) <= 'Z') || ((c) >= 'a' && (c) <= 'z')) -#endif - -#ifndef digit_value -#define digit_value(c) ((c) - '0') -#endif - -#ifndef member -char *index (); -#define member(c, s) ((c) ? index ((s), (c)) : 0) -#endif - -#ifndef isident -#define isident(c) ((isletter(c) || digit(c) || c == '_')) -#endif - -#ifndef exchange -#define exchange(x, y) {int temp = x; x = y; y = temp;} -#endif - -static update_line (); -static void output_character_function (); -static delete_chars (); -static delete_chars (); -static insert_some_chars (); - -void rl_safe_insert_text(); - -#ifdef VOID_SIGHANDLER -#define sighandler void -#else -#define sighandler int -#endif - -/* This typedef is equivalant to the one for Function; it allows us - to say SigHandler *foo = signal (SIGKILL, SIG_IGN); */ -typedef sighandler SigHandler (); - -#ifdef SIGWINCH -static sighandler rl_handle_sigwinch (); -static SigHandler *old_sigwinch = (SigHandler *)NULL; -#endif - -/* If on, then readline handles signals in a way that doesn't screw. */ -#define HANDLE_SIGNALS - -#if defined (SYSV) -#ifdef HANDLE_SIGNALS -#undef HANDLE_SIGNALS -#endif -#endif - - -/* **************************************************************** */ -/* */ -/* Line editing input utility */ -/* */ -/* **************************************************************** */ - -/* A pointer to the keymap that is currently in use. - By default, it is the standard emacs keymap. */ -Keymap keymap = emacs_standard_keymap; - -#define vi_mode 0 -#define emacs_mode 1 - -/* The current style of editing. */ -int rl_editing_mode = emacs_mode; - -/* Non-zero if the previous command was a kill command. */ -static int last_command_was_kill = 0; - -/* The current value of the numeric argument specified by the user. */ -int rl_numeric_arg = 1; - -/* Non-zero if an argument was typed. */ -int rl_explicit_arg = 0; - -/* Temporary value used while generating the argument. */ -static int arg_sign = 1; - -/* Non-zero means we have been called at least once before. */ -static int rl_initialized = 0; - -/* If non-zero, this program is running in an EMACS buffer. */ -static char *running_in_emacs = (char *)NULL; - -/* The current offset in the current input line. */ -int rl_point; - -/* Mark in the current input line. */ -int rl_mark; - -/* Length of the current input line. */ -int rl_end; - -/* Make this non-zero to return the current input_line. */ -int rl_done; - -/* The last function executed by readline. */ -Function *rl_last_func = (Function *)NULL; - -/* Top level environment for readline_internal (). */ -static jmp_buf readline_top_level; - -/* The streams we interact with. */ -static FILE *in_stream, *out_stream; - -/* The names of the streams that we do input and output to. */ -FILE *rl_instream = stdin, *rl_outstream = stdout; - -/* Non-zero means echo characters as they are read. */ -int readline_echoing_p = 1; - -/* Current prompt. */ -char *rl_prompt; - -/* The number of characters read in order to type this complete command. */ -int rl_key_sequence_length = 0; - -/* 1 means the line editor is active. */ -int rl_active = 0; - -/* 1 means we are waiting for a character. */ -int rl_waiting = 0; - -/* If non-zero, then this is the address of a function to call just - before readline_internal () prints the first prompt. */ -Function *rl_startup_hook = (Function *)NULL; - -/* What we use internally. You should always refer to RL_LINE_BUFFER. */ -static char *the_line; - -/* The character that can generate an EOF. Really read from - the terminal driver... just defaulted here. */ -static int eof_char = CTRL ('D'); - -/* Non-zero makes this the next keystroke to read. */ -int rl_pending_input = 0; - -/* Pointer to a useful terminal name. */ -char *rl_terminal_name = (char *)NULL; - -/* Line buffer and maintenence. */ -char *rl_line_buffer = (char *)NULL; -static int rl_line_buffer_len = 0; -#define DEFAULT_BUFFER_SIZE 256 - - -/* **************************************************************** */ -/* */ -/* `Forward' declarations */ -/* */ -/* **************************************************************** */ - -/* Non-zero means do not parse any lines other than comments and - parser directives. */ -static unsigned char parsing_conditionalized_out = 0; - -/* Caseless strcmp (). */ -static int stricmp (), strnicmp (); - -/* Non-zero means to save keys that we dispatch on in a kbd macro. */ -static int defining_kbd_macro = 0; - - -/* **************************************************************** */ -/* */ -/* Top Level Functions */ -/* */ -/* **************************************************************** */ - -/* Read a line of input. Prompt with PROMPT. A NULL PROMPT means - none. A return value of NULL means that EOF was encountered. */ -char * -readline (prompt) -char *prompt; -{ - int rl_prep_terminal (), rl_deprep_terminal (); - char *readline_internal (); - char *value; - - rl_prompt = prompt; - - /* If we are at EOF return a NULL string. */ - if (rl_pending_input == EOF) - { - rl_pending_input = 0; - return ((char *)NULL); - } - - rl_initialize (); - rl_prep_terminal (); - -#ifdef SIGWINCH - old_sigwinch = (SigHandler *)signal (SIGWINCH, rl_handle_sigwinch); -#endif - -#ifdef HANDLE_SIGNALS - rl_set_signals (); -#endif - - rl_active = 1; - rl_waiting = 0; - value = readline_internal (); - rl_active = 0; - rl_deprep_terminal (); - -#ifdef SIGWINCH - signal (SIGWINCH, old_sigwinch); -#endif - -#ifdef HANDLE_SIGNALS - rl_clear_signals (); -#endif - - return (value); -} - -/* Read a line of input from the global rl_instream, doing output on - the global rl_outstream. - If rl_prompt is non-null, then that is our prompt. */ -char * -readline_internal () -{ - int lastc, c, eof_found; - - in_stream = rl_instream; - out_stream = rl_outstream; - lastc = eof_found = 0; - - if (rl_startup_hook) - (*rl_startup_hook) (); - - if (!readline_echoing_p) - { - if (rl_prompt) - { - fprintf (out_stream, "%s", rl_prompt); - fflush (out_stream); - } - } - else - { - rl_on_new_line (); - rl_redisplay (); -#ifdef VI_MODE - if (rl_editing_mode == vi_mode) - rl_vi_insertion_mode (); -#endif /* VI_MODE */ - } - - while (!rl_done) - { - int lk = last_command_was_kill; - int code = setjmp (readline_top_level); - - if (code) - rl_redisplay (); - - if (!rl_pending_input) - { - /* Then initialize the argument and number of keys read. */ - rl_init_argument (); - rl_key_sequence_length = 0; - } - - c = rl_read_key (); - if (c == EOF) - { - eof_found = 1; - putc('\n',stderr); - break; - } - - /* EOF typed to a non-blank line is a . */ - if (c == EOF && rl_end) - c = NEWLINE; - - if (errflag) - { - eof_found = 1; - break; - } - - /* The character eof_char typed to blank line, and not as the - previous character is interpreted as EOF. */ - if (((c == eof_char && lastc != c) || c == EOF) && !rl_end) - { - eof_found = 1; - break; - } - - lastc = c; - rl_dispatch (c, keymap); - - /* If there was no change in last_command_was_kill, then no kill - has taken place. Note that if input is pending we are reading - a prefix command, so nothing has changed yet. */ - if (!rl_pending_input) - { - if (lk == last_command_was_kill) - last_command_was_kill = 0; - } - -#ifdef VI_MODE - /* In vi mode, when you exit insert mode, the cursor moves back - over the previous character. We explicitly check for that here. */ - if (rl_editing_mode == vi_mode && keymap == vi_movement_keymap) - rl_vi_check (); -#endif - if (!rl_done) - rl_redisplay (); - } - - /* Restore the original of this history line, iff the line that we - are editing was originally in the history, AND the line has changed. */ - { - HIST_ENTRY *entry = current_history (); - - if (entry && rl_undo_list) - { - char *temp = savestring (the_line); - rl_revert_line (); - free_history_entry (entry); - - strcpy (the_line, temp); - free (temp); - } - } - - /* At any rate, it is highly likely that this line has an undo list. Get - rid of it now. */ - if (rl_undo_list) - free_undo_list (); - - if (eof_found) - return (char *)NULL; - else - return (savestring (the_line)); -} - - -/* **************************************************************** */ -/* */ -/* Signal Handling */ -/* */ -/* **************************************************************** */ - -#ifdef SIGWINCH -static sighandler -rl_handle_sigwinch (sig, code, scp) -int sig, code; -struct sigcontext *scp; -{ - char *term = rl_terminal_name, *getenv (); - - if (readline_echoing_p) - { - if (!term) - term = getenv ("TERM"); - if (!term) - term = "dumb"; - rl_reset_terminal (term); -#ifdef NEVER - crlf (); - rl_forced_update_display (); -#endif - } - - if (old_sigwinch && - old_sigwinch != (SigHandler *)SIG_IGN && - old_sigwinch != (SigHandler *)SIG_DFL) - (*old_sigwinch)(sig, code, scp); -} -#endif /* SIGWINCH */ - -#ifdef HANDLE_SIGNALS -/* Interrupt handling. */ -static SigHandler *old_int = (SigHandler *)NULL, -*old_tstp = (SigHandler *)NULL, -*old_ttou = (SigHandler *)NULL, -*old_ttin = (SigHandler *)NULL, -*old_cont = (SigHandler *)NULL; - -/* Handle an interrupt character. */ -static sighandler -rl_signal_handler (sig, code, scp) -int sig, code; -struct sigcontext *scp; -{ - rl_prep_terminal (), rl_deprep_terminal (); - - switch (sig) - { - case SIGINT: - free_undo_list (); - rl_clear_message (); - rl_init_argument (); -#ifdef SIGWINCH - signal (SIGWINCH, old_sigwinch); -#endif - -#ifdef SIGTSTP - case SIGTSTP: - case SIGTTOU: - case SIGTTIN: -#endif - - rl_clean_up_for_exit (); - rl_deprep_terminal (); - rl_clear_signals (); - rl_pending_input = 0; - - kill (getpid (), sig); - sigsetmask (0); - - rl_prep_terminal (); - rl_set_signals (); - } -} - -rl_set_signals () -{ - old_int = (SigHandler *)signal (SIGINT, rl_signal_handler); - if (old_int == (SigHandler *)SIG_IGN) - signal (SIGINT, SIG_IGN); - -#ifdef SIGTSTP - old_tstp = (SigHandler *)signal (SIGTSTP, rl_signal_handler); - if (old_tstp == (SigHandler *)SIG_IGN) - signal (SIGTSTP, SIG_IGN); -#endif -#ifdef SIGTTOU - old_ttou = (SigHandler *)signal (SIGTTOU, rl_signal_handler); - old_ttin = (SigHandler *)signal (SIGTTIN, rl_signal_handler); - - if (old_tstp == (SigHandler *)SIG_IGN) - { - signal (SIGTTOU, SIG_IGN); - signal (SIGTTIN, SIG_IGN); - } -#endif -} - -rl_clear_signals () -{ - signal (SIGINT, old_int); - -#ifdef SIGTSTP - signal (SIGTSTP, old_tstp); -#endif -#ifdef SIGTTOU - signal (SIGTTOU, old_ttou); - signal (SIGTTIN, old_ttin); -#endif -} -#endif /* HANDLE_SIGNALS */ - - -/* **************************************************************** */ -/* */ -/* Character Input Buffering */ -/* */ -/* **************************************************************** */ - -/* If the terminal was in xoff state when we got to it, then xon_char - contains the character that is supposed to start it again. */ -static int xon_char, xoff_state; -static int pop_index = 0, push_index = 0, ibuffer_len = 511; -static unsigned char ibuffer[512]; - -/* Non-null means it is a pointer to a function to run while waiting for - character input. */ -Function *rl_event_hook = (Function *)NULL; - -#define any_typein (push_index != pop_index) - -/* Add KEY to the buffer of characters to be read. */ -rl_stuff_char (key) -int key; -{ - if (key == EOF) - { - key = NEWLINE; - rl_pending_input = EOF; - } - ibuffer[push_index++] = key; - if (push_index >= ibuffer_len) - push_index = 0; -} - -/* Return the amount of space available in the - buffer for stuffing characters. */ -int -ibuffer_space () -{ - if (pop_index > push_index) - return (pop_index - push_index); - else - return (ibuffer_len - (push_index - pop_index)); -} - -/* Get a key from the buffer of characters to be read. - Return the key in KEY. - Result is KEY if there was a key, or 0 if there wasn't. */ -int -rl_get_char (key) -int *key; -{ - if (push_index == pop_index) - return (0); - - *key = ibuffer[pop_index++]; - - if (pop_index >= ibuffer_len) - pop_index = 0; - - return (1); -} - -/* Stuff KEY into the *front* of the input buffer. - Returns non-zero if successful, zero if there is - no space left in the buffer. */ -int -rl_unget_char (key) -int key; -{ - if (ibuffer_space ()) - { - pop_index--; - if (pop_index < 0) - pop_index = ibuffer_len - 1; - ibuffer[pop_index] = key; - return (1); - } - return (0); -} - -/* If a character is available to be read, then read it - and stuff it into IBUFFER. Otherwise, just return. */ -rl_gather_tyi () -{ - int tty = fileno (in_stream); - register int tem, result = -1; - long chars_avail; - char input; - -#ifdef FIONREAD - result = ioctl (tty, FIONREAD, &chars_avail); -#endif - - if (result == -1) - { - fcntl (tty, F_SETFL, O_NDELAY); - chars_avail = read (tty, &input, 1); - fcntl (tty, F_SETFL, 0); - if (chars_avail == -1 && errno == EAGAIN) - return; - } - - tem = ibuffer_space (); - - if (chars_avail > tem) - chars_avail = tem; - - /* One cannot read all of the available input. I can only read a single - character at a time, or else programs which require input can be - thwarted. If the buffer is larger than one character, I lose. - Damn! */ - if (tem < ibuffer_len) - chars_avail = 0; - - if (result != -1) - { - while (chars_avail--) - rl_stuff_char (rl_getc (in_stream)); - } - else - { - if (chars_avail) - rl_stuff_char (input); - } -} - -/* Read a key, including pending input. */ -int -rl_read_key () -{ - int c; - - rl_key_sequence_length++; - - if (rl_pending_input) - { - c = rl_pending_input; - rl_pending_input = 0; - } - else - { - static int next_macro_key (); - - /* If input is coming from a macro, then use that. */ - if (c = next_macro_key ()) - return (c); - - /* If the user has an event function, then call it periodically. */ - if (rl_event_hook) - { - while (rl_event_hook && !rl_get_char (&c)) - { - (*rl_event_hook) (); - rl_gather_tyi (); - } - } - else - { - if (!rl_get_char (&c)) - c = rl_getc (in_stream); - } - } - -#ifdef NEVER /* This breaks supdup to 4.0.3c machines. */ -#ifdef TIOCSTART - /* Ugh. But I can't think of a better way. */ - if (xoff_state && c == xon_char) - { - ioctl (fileno (in_stream), TIOCSTART, 0); - xoff_state = 0; - return (rl_read_key ()); - } -#endif /* TIOCSTART */ -#endif - - return (c); -} - -/* I'm beginning to hate the declaration rules for various compilers. */ -static void add_macro_char (); - -/* Do the command associated with KEY in MAP. - If the associated command is really a keymap, then read - another key, and dispatch into that map. */ -rl_dispatch (key, map) -register int key; -Keymap map; -{ - - if (defining_kbd_macro) - add_macro_char (key); - - if (key > 127 && key < 256) - { - if (map[ESC].type == ISKMAP) - { - map = (Keymap)map[ESC].function; - key -= 128; - rl_dispatch (key, map); - } - else - ding (); - return; - } - - switch (map[key].type) - { - case ISFUNC: - { - Function *func = map[key].function; - - if (func != (Function *)NULL) - { - /* Special case rl_do_lowercase_version (). */ - if (func == rl_do_lowercase_version) - { - rl_dispatch (to_lower (key), map); - return; - } - - (*map[key].function)(rl_numeric_arg * arg_sign, key); - } - else - { - ding (); - return; - } - } - break; - - case ISKMAP: - if (map[key].function != (Function *)NULL) - { - int newkey; - - rl_key_sequence_length++; - newkey = rl_read_key (); - rl_dispatch (newkey, (Keymap)map[key].function); - } - else - { - ding (); - return; - } - break; - - case ISMACR: - if (map[key].function != (Function *)NULL) - { - static with_macro_input (); - char *macro = savestring ((char *)map[key].function); - - with_macro_input (macro); - return; - } - break; - } - - /* If we have input pending, then the last command was a prefix - command. Don't change the state of rl_last_func. */ - if (!rl_pending_input) - rl_last_func = map[key].function; -} - - -/* **************************************************************** */ -/* */ -/* Hacking Keyboard Macros */ -/* */ -/* **************************************************************** */ - -/* The currently executing macro string. If this is non-zero, - then it is a malloc ()'ed string where input is coming from. */ -static char *executing_macro = (char *)NULL; - -/* The offset in the above string to the next character to be read. */ -static int executing_macro_index = 0; - -/* The current macro string being built. Characters get stuffed - in here by add_macro_char (). */ -static char *current_macro = (char *)NULL; - -/* The size of the buffer allocated to current_macro. */ -static int current_macro_size = 0; - -/* The index at which characters are being added to current_macro. */ -static int current_macro_index = 0; - -/* A structure used to save nested macro strings. - It is a linked list of string/index for each saved macro. */ -struct saved_macro { - struct saved_macro *next; - char *string; - int index; -}; - -/* The list of saved macros. */ -struct saved_macro *macro_list = (struct saved_macro *)NULL; - -/* Forward declarations of static functions. Thank you C. */ -static void push_executing_macro (), pop_executing_macro (); - -/* This one has to be declared earlier in the file. */ -/* static void add_macro_char (); */ - -/* Set up to read subsequent input from STRING. - STRING is free ()'ed when we are done with it. */ -static -with_macro_input (string) -char *string; -{ - push_executing_macro (); - executing_macro = string; - executing_macro_index = 0; -} - -/* Return the next character available from a macro, or 0 if - there are no macro characters. */ -static int -next_macro_key () -{ - if (!executing_macro) - return (0); - - if (!executing_macro[executing_macro_index]) - { - pop_executing_macro (); - return (next_macro_key ()); - } - - return (executing_macro[executing_macro_index++]); -} - -/* Save the currently executing macro on a stack of saved macros. */ -static void -push_executing_macro () -{ - struct saved_macro *saver; - - saver = (struct saved_macro *)xmalloc (sizeof (struct saved_macro)); - saver->next = macro_list; - saver->index = executing_macro_index; - saver->string = executing_macro; - - macro_list = saver; -} - -/* Discard the current macro, replacing it with the one - on the top of the stack of saved macros. */ -static void -pop_executing_macro () -{ - if (executing_macro) - free (executing_macro); - - executing_macro = (char *)NULL; - executing_macro_index = 0; - - if (macro_list) - { - struct saved_macro *disposer = macro_list; - executing_macro = macro_list->string; - executing_macro_index = macro_list->index; - macro_list = macro_list->next; - free (disposer); - } -} - -/* Add a character to the macro being built. */ -static void -add_macro_char (c) -int c; -{ - if (current_macro_index + 1 >= current_macro_size) - { - if (!current_macro) - current_macro = (char *)xmalloc (current_macro_size = 25); - else - current_macro = - (char *)xrealloc (current_macro, current_macro_size += 25); - } - - current_macro[current_macro_index++] = c; - current_macro[current_macro_index] = '\0'; -} - -/* Begin defining a keyboard macro. - Keystrokes are recorded as they are executed. - End the definition with rl_end_kbd_macro (). - If a numeric argument was explicitly typed, then append this - definition to the end of the existing macro, and start by - re-executing the existing macro. */ -rl_start_kbd_macro (ignore1, ignore2) -int ignore1, ignore2; -{ - if (defining_kbd_macro) - rl_abort (); - - if (rl_explicit_arg) - { - if (current_macro) - with_macro_input (savestring (current_macro)); - } - else - current_macro_index = 0; - - defining_kbd_macro = 1; -} - -/* Stop defining a keyboard macro. - A numeric argument says to execute the macro right now, - that many times, counting the definition as the first time. */ -rl_end_kbd_macro (count, ignore) -int count, ignore; -{ - if (!defining_kbd_macro) - rl_abort (); - - current_macro_index -= (rl_key_sequence_length - 1); - current_macro[current_macro_index] = '\0'; - - defining_kbd_macro = 0; - - rl_call_last_kbd_macro (--count, 0); -} - -/* Execute the most recently defined keyboard macro. - COUNT says how many times to execute it. */ -rl_call_last_kbd_macro (count, ignore) -int count, ignore; -{ - if (!current_macro) - rl_abort (); - - while (count--) - with_macro_input (savestring (current_macro)); -} - - -/* **************************************************************** */ -/* */ -/* Initializations */ -/* */ -/* **************************************************************** */ - -/* Initliaze readline (and terminal if not already). */ -rl_initialize () -{ - extern char *rl_display_prompt; - - /* If we have never been called before, initialize the - terminal and data structures. */ - if (!rl_initialized) - { - readline_initialize_everything (); - rl_initialized++; - } - - /* Initalize the current line information. */ - rl_point = rl_end = 0; - the_line = rl_line_buffer; - the_line[0] = 0; - - /* We aren't done yet. We haven't even gotten started yet! */ - rl_done = 0; - - /* Tell the history routines what is going on. */ - start_using_history (); - - /* Make the display buffer match the state of the line. */ - { - extern char *rl_display_prompt; - extern int forced_display; - - rl_on_new_line (); - - rl_display_prompt = rl_prompt ? rl_prompt : ""; - forced_display = 1; - } - - /* No such function typed yet. */ - rl_last_func = (Function *)NULL; - - /* Parsing of key-bindings begins in an enabled state. */ - parsing_conditionalized_out = 0; -} - -/* Initialize the entire state of the world. */ -readline_initialize_everything () -{ - /* Find out if we are running in Emacs. */ - running_in_emacs = (char *)getenv ("EMACS"); - - /* Allocate data structures. */ - if (!rl_line_buffer) - rl_line_buffer = - (char *)xmalloc (rl_line_buffer_len = DEFAULT_BUFFER_SIZE); - - /* Initialize the terminal interface. */ - init_terminal_io ((char *)NULL); - - /* Bind tty characters to readline functions. */ - readline_default_bindings (); - - /* Initialize the function names. */ - rl_initialize_funmap (); - - /* Read in the init file. */ - rl_read_init_file ((char *)NULL); - - /* If the completion parser's default word break characters haven't - been set yet, then do so now. */ - { - extern char *rl_completer_word_break_characters; - extern char *rl_basic_word_break_characters; - - if (rl_completer_word_break_characters == (char *)NULL) - rl_completer_word_break_characters = rl_basic_word_break_characters; - } -} - -/* If this system allows us to look at the values of the regular - input editing characters, then bind them to their readline - equivalents. */ -readline_default_bindings () -{ - -#ifdef NEW_TTY_DRIVER - struct sgttyb ttybuff; - int tty = fileno (rl_instream); - - if (ioctl (tty, TIOCGETP, &ttybuff) != -1) - { - int erase = ttybuff.sg_erase, kill = ttybuff.sg_kill; - - if (erase != -1 && keymap[erase].type == ISFUNC) - keymap[erase].function = rl_rubout; - - if (kill != -1 && keymap[kill].type == ISFUNC) - keymap[kill].function = rl_unix_line_discard; - } - -#ifdef TIOCGLTC - { - struct ltchars lt; - - if (ioctl (tty, TIOCGLTC, <) != -1) - { - int erase = lt.t_werasc, nextc = lt.t_lnextc; - - if (erase != -1 && keymap[erase].type == ISFUNC) - keymap[erase].function = rl_unix_word_rubout; - - if (nextc != -1 && keymap[nextc].type == ISFUNC) - keymap[nextc].function = rl_quoted_insert; - } - } -#endif /* TIOCGLTC */ -#else /* not NEW_TTY_DRIVER */ - struct termio ttybuff; - int tty = fileno (rl_instream); - - if (ioctl (tty, TCGETA, &ttybuff) != -1) - { - int erase = ttybuff.c_cc[VERASE]; - int kill = ttybuff.c_cc[VKILL]l - - if (erase != -1 && keymap[(unsigned char)erase].type == ISFUNC) - keymap[(unsigned char)erase].function = rl_rubout; - - if (kill != -1 && keymap[(unsigned char)kill].type == ISFUNC) - keymap[(unsigned char)kill].function = rl_unix_line_discard; - } -#endif /* NEW_TTY_DRIVER */ -} - - -/* **************************************************************** */ -/* */ -/* Numeric Arguments */ -/* */ -/* **************************************************************** */ - -/* Handle C-u style numeric args, as well as M--, and M-digits. */ - -/* Add the current digit to the argument in progress. */ -rl_digit_argument (ignore, key) -int ignore, key; -{ - rl_pending_input = key; - rl_digit_loop (); -} - -/* What to do when you abort reading an argument. */ -rl_discard_argument () -{ - ding (); - rl_clear_message (); - rl_init_argument (); -} - -/* Create a default argument. */ -rl_init_argument () -{ - rl_numeric_arg = arg_sign = 1; - rl_explicit_arg = 0; -} - -/* C-u, universal argument. Multiply the current argument by 4. - Read a key. If the key has nothing to do with arguments, then - dispatch on it. If the key is the abort character then abort. */ -rl_universal_argument () -{ - rl_numeric_arg *= 4; - rl_digit_loop (); -} - -rl_digit_loop () -{ - int key, c; - while (1) - { - rl_message ("(arg: %d) ", arg_sign * rl_numeric_arg); - key = c = rl_read_key (); - - if (keymap[c].type == ISFUNC && - keymap[c].function == rl_universal_argument) - { - rl_numeric_arg *= 4; - continue; - } - c = UNMETA (c); - if (numeric (c)) - { - if (rl_explicit_arg) - rl_numeric_arg = (rl_numeric_arg * 10) + (c - '0'); - else - rl_numeric_arg = (c - '0'); - rl_explicit_arg = 1; - } - else - { - if (c == '-' && !rl_explicit_arg) - { - rl_numeric_arg = 1; - arg_sign = -1; - } - else - { - rl_clear_message (); - rl_dispatch (key, keymap); - return; - } - } - } -} - - -/* **************************************************************** */ -/* */ -/* Display stuff */ -/* */ -/* **************************************************************** */ - -/* This is the stuff that is hard for me. I never seem to write good - display routines in C. Let's see how I do this time. */ - -/* (PWP) Well... Good for a simple line updater, but totally ignores - the problems of input lines longer than the screen width. - - update_line and the code that calls it makes a multiple line, - automatically wrapping line update. Carefull attention needs - to be paid to the vertical position variables. - - handling of terminals with autowrap on (incl. DEC braindamage) - could be improved a bit. Right now I just cheat and decrement - screenwidth by one. */ - -/* Keep two buffers; one which reflects the current contents of the - screen, and the other to draw what we think the new contents should - be. Then compare the buffers, and make whatever changes to the - screen itself that we should. Finally, make the buffer that we - just drew into be the one which reflects the current contents of the - screen, and place the cursor where it belongs. - - Commands that want to can fix the display themselves, and then let - this function know that the display has been fixed by setting the - RL_DISPLAY_FIXED variable. This is good for efficiency. */ - -/* Termcap variables: */ -extern char *term_up, *term_dc, *term_cr; -extern int screenheight, screenwidth, terminal_can_insert; - ---cut here---cut here---cut here---