diff options
Diffstat (limited to 'Src')
-rw-r--r-- | Src/prompt.c | 53 |
1 files changed, 46 insertions, 7 deletions
diff --git a/Src/prompt.c b/Src/prompt.c index 9b6edfcc6..06dd2e5a9 100644 --- a/Src/prompt.c +++ b/Src/prompt.c @@ -574,15 +574,54 @@ putpromptchar(int doprint, int endchar) case 'E': tsetcap(TCCLEAREOL, 1); break; + case '^': + if (cmdsp) { + if (arg >= 0) { + if (arg > cmdsp || arg == 0) + arg = cmdsp; + for (t0 = cmdsp - 1; arg--; t0--) { + stradd(cmdnames[cmdstack[t0]]); + if (arg) { + addbufspc(1); + *bp++=' '; + } + } + } else { + arg = -arg; + if (arg > cmdsp) + arg = cmdsp; + for (t0 = arg - 1; arg--; t0--) { + stradd(cmdnames[cmdstack[t0]]); + if (arg) { + addbufspc(1); + *bp++=' '; + } + } + } + } + break; case '_': if (cmdsp) { - if (arg > cmdsp || arg <= 0) - arg = cmdsp; - for (t0 = cmdsp - arg; arg--; t0++) { - stradd(cmdnames[cmdstack[t0]]); - if (arg) { - addbufspc(1); - *bp++=' '; + if (arg >= 0) { + if (arg > cmdsp || arg == 0) + arg = cmdsp; + for (t0 = cmdsp - arg; arg--; t0++) { + stradd(cmdnames[cmdstack[t0]]); + if (arg) { + addbufspc(1); + *bp++=' '; + } + } + } else { + arg = -arg; + if (arg > cmdsp) + arg = cmdsp; + for (t0 = 0; arg--; t0++) { + stradd(cmdnames[cmdstack[t0]]); + if (arg) { + addbufspc(1); + *bp++=' '; + } } } } |