Fixed issues with the alternate prompt
This commit is contained in:
parent
3bcc4af957
commit
a1991eee19
|
|
@ -533,6 +533,51 @@ doblock(struct control *bl, int *num)
|
||||||
return (NORMAL_STR);
|
return (NORMAL_STR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Maxiumum number of cheverons used for the alternative prompt */
|
||||||
|
#define MAX_CHEVRONS 16
|
||||||
|
|
||||||
|
/* Get the alternate prompt.
|
||||||
|
Number of chevrons indicates stack depth.
|
||||||
|
Returns NULL when there is no alternate prompt.
|
||||||
|
SJB 28th April 2005 */
|
||||||
|
char *
|
||||||
|
get_alt_prompt(void)
|
||||||
|
{
|
||||||
|
int i = 0, j;
|
||||||
|
static char buf[MAX_CHEVRONS + 2]; /* includes terminating space & null */
|
||||||
|
struct control *c;
|
||||||
|
|
||||||
|
/* if nothing on the command stack return NULL */
|
||||||
|
if (cend[stackp] <= 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
/* measure stack depth */
|
||||||
|
for (c = cend[stackp]->co_parent; c; c = c->co_parent)
|
||||||
|
i++;
|
||||||
|
|
||||||
|
if (i <= 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
/* Avoid overflow of buffer and
|
||||||
|
indicate when we've limited the chevrons by starting with a '+' */
|
||||||
|
if(i > MAX_CHEVRONS) {
|
||||||
|
i = MAX_CHEVRONS;
|
||||||
|
buf[0]='+';
|
||||||
|
} else {
|
||||||
|
buf[0]='>';
|
||||||
|
}
|
||||||
|
|
||||||
|
/* return one chevron per command stack depth */
|
||||||
|
for (j = 1; j < i; j++)
|
||||||
|
buf[j] = '>';
|
||||||
|
|
||||||
|
/* Add space and terminate */
|
||||||
|
buf[j] = ' ';
|
||||||
|
buf[j + 1] = '\0';
|
||||||
|
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Get a command. This does all the bookkeeping things like turning
|
/* Get a command. This does all the bookkeeping things like turning
|
||||||
* command completion on and off... */
|
* command completion on and off... */
|
||||||
|
|
@ -540,26 +585,14 @@ static wordlist *
|
||||||
getcommand(char *string)
|
getcommand(char *string)
|
||||||
{
|
{
|
||||||
wordlist *wlist;
|
wordlist *wlist;
|
||||||
int i = 0, j;
|
|
||||||
static char buf[64];
|
|
||||||
struct control *c;
|
|
||||||
|
|
||||||
if (cp_debug)
|
if (cp_debug)
|
||||||
fprintf(cp_err, "calling getcommand %s\n",
|
fprintf(cp_err, "calling getcommand %s\n", string ? string : "");
|
||||||
string ? string : "");
|
|
||||||
if (cend[stackp]) {
|
#ifndef HAVE_GNUREADLINE
|
||||||
for (c = cend[stackp]->co_parent; c; c = c->co_parent)
|
/* set cp_altprompt for use by the lexer - see parser/lexical.c */
|
||||||
i++;
|
cp_altprompt = get_alt_prompt();
|
||||||
if (i) {
|
#endif
|
||||||
for (j = 0; j < i; j++)
|
|
||||||
buf[j] = '>';
|
|
||||||
buf[j] = ' ';
|
|
||||||
buf[j + 1] = '\0';
|
|
||||||
cp_altprompt = buf;
|
|
||||||
} else
|
|
||||||
cp_altprompt = NULL;
|
|
||||||
} else
|
|
||||||
cp_altprompt = NULL;
|
|
||||||
|
|
||||||
cp_cwait = TRUE;
|
cp_cwait = TRUE;
|
||||||
wlist = cp_parse(string);
|
wlist = cp_parse(string);
|
||||||
|
|
|
||||||
|
|
@ -66,18 +66,22 @@ extern void cp_ioreset();
|
||||||
extern wordlist *cp_redirect();
|
extern wordlist *cp_redirect();
|
||||||
extern wordlist *cp_parse();
|
extern wordlist *cp_parse();
|
||||||
|
|
||||||
/* front.c */
|
/* control.c */
|
||||||
|
|
||||||
extern bool cp_cwait;
|
extern bool cp_cwait;
|
||||||
extern bool cp_dounixcom;
|
extern bool cp_dounixcom;
|
||||||
extern char *cp_csep;
|
extern char *cp_csep;
|
||||||
|
extern char * get_alt_prompt(void);
|
||||||
extern int cp_evloop(char *string);
|
extern int cp_evloop(char *string);
|
||||||
extern void com_cdump(wordlist *wl);
|
|
||||||
extern void cp_resetcontrol(void);
|
extern void cp_resetcontrol(void);
|
||||||
extern void cp_toplevel(void);
|
extern void cp_toplevel(void);
|
||||||
extern void cp_popcontrol(void);
|
extern void cp_popcontrol(void);
|
||||||
extern void cp_pushcontrol(void);
|
extern void cp_pushcontrol(void);
|
||||||
|
|
||||||
|
/* com_cdump.c */
|
||||||
|
|
||||||
|
extern void com_cdump(wordlist *wl);
|
||||||
|
|
||||||
/* glob.c */
|
/* glob.c */
|
||||||
|
|
||||||
extern bool cp_globmatch(char *p, char *s);
|
extern bool cp_globmatch(char *p, char *s);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue