#include #include #include #include "header.h" #include "sysdep.h" #include "graphics.h" char fktext [10][64]; #define MAXHIST 32 char history [MAXHIST][128]; int act_history=0,hist=0; extern int outputing; void cpy (char *dest, char *source) { memmove(dest,source,strlen(source)+1); } void put_history (char *s) { int i; if (act_history>=MAXHIST) { for (i=0; i"); if (!udf) output(">"); else output("udf>"); } void left (int n) { int i; for (i=0; i=254) return; cpy(s+*pos+strlen(p),s+*pos); memmove(s+*pos,p,strlen(p)); output1("%s",p); *pos+=(int)strlen(p); } char helpstart[256]; char helpextend[16][16]; int helpn=0,helpnext=0,helphist=-1; int dohelp (char start[256], char extend[16][16]); void edithelp (char *s, int *pos, int *shorter) /* extend the command at cursor position */ { char *start,*end,*p; int i,l; /* search history */ l=(int)strlen(s); helphist=-1; for (i=act_history-1; i>=0; i--) if (!strncmp(history[i],s,l)) { helphist=i; break; } start=end=p=s+(*pos); while (start>s && (isalpha(*(start-1)) || isdigit(*(start-1)))) start--; while (isdigit(*start)) start++; while (isalpha(*end) || isdigit(*end)) end++; if (start>s+(*pos) || start>=end) return; while (p=helpn && helphist<0) { edithelp(s,&pos,&shorter); p=0; } if (helphist>=0) { cursor_off(); strcpy(s,history[helphist]); hist=helphist; p=s+pos; output1("%s",p); pos+=(int)strlen(p); shorter=1; helphist=-1; goto cont; } else if (helpnext=254) { p=0; helpn=0; break; } cpy(s+pos+strlen(p),s+pos); memmove(s+pos,p,strlen(p)); output1("%s",p); pos+=(int)strlen(p); shorter=1; goto cont; } break; case fk1 : fkinsert(0,&pos,s); break; case fk2 : fkinsert(1,&pos,s); break; case fk3 : fkinsert(2,&pos,s); break; case fk4 : fkinsert(3,&pos,s); break; case fk5 : fkinsert(4,&pos,s); break; case fk6 : fkinsert(5,&pos,s); break; case fk7 : fkinsert(6,&pos,s); break; case fk8 : fkinsert(7,&pos,s); break; case fk9 : fkinsert(8,&pos,s); break; case fk10 : fkinsert(9,&pos,s); break; } cursor_off(); } cont: gprint(s+pos); if (shorter) clear_eol(); left((int)strlen(s+pos)); cursor_on(); } put_history(s); if (outfile) { fprintf(outfile,"%s",s); } edit_off(); output("\n"); }