SCP: Enhance hierarchical help prompting
- A prompt answer which exactly matches a topic name is given preference over the potential ambiguity of other topics which start with the same text. - Prompt with the parent topic's prompt when a just displayed subtopic has no subtopics. - Allow either ^D or ^Z entered to act as EOF. These changes reflect the behavior of the VMS help system which the hierarchical help system is modeled on.
This commit is contained in:
parent
9166219476
commit
0bfb902b56
1 changed files with 8 additions and 0 deletions
8
scp.c
8
scp.c
|
@ -14561,6 +14561,8 @@ for (i = 0; i < topic->kids; i++) {
|
||||||
cptr++;
|
cptr++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!strcmp (cbuf, token)) /* Exact Match */
|
||||||
|
return i+1;
|
||||||
if (!strncmp (cbuf, token, strlen (token))) {
|
if (!strncmp (cbuf, token, strlen (token))) {
|
||||||
if (match)
|
if (match)
|
||||||
return HLP_MATCH_AMBIGUOUS;
|
return HLP_MATCH_AMBIGUOUS;
|
||||||
|
@ -14745,10 +14747,16 @@ while (TRUE) {
|
||||||
|
|
||||||
reprompt:
|
reprompt:
|
||||||
if (!cptr || !*cptr) {
|
if (!cptr || !*cptr) {
|
||||||
|
if (topic->kids == 0)
|
||||||
|
topic = topic->parent;
|
||||||
pstring = helpPrompt (topic, prompt[topic->kids != 0], FALSE);
|
pstring = helpPrompt (topic, prompt[topic->kids != 0], FALSE);
|
||||||
|
|
||||||
cptr = read_line_p (pstring, cbuf, sizeof (cbuf), stdin);
|
cptr = read_line_p (pstring, cbuf, sizeof (cbuf), stdin);
|
||||||
free (pstring);
|
free (pstring);
|
||||||
|
if ((cptr != NULL) && /* Got something? */
|
||||||
|
((0 == strcmp (cptr, "\x04")) || /* was it a bare ^D? */
|
||||||
|
(0 == strcmp (cptr, "\x1A")))) /* was it a bare ^Z? */
|
||||||
|
cptr = NULL; /* These are EOF synonyms */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cptr) { /* EOF, exit help */
|
if (!cptr) { /* EOF, exit help */
|
||||||
|
|
Loading…
Add table
Reference in a new issue