diff --git a/top/top.c b/top/top.c index 94f4f1d1..ea31b6ce 100644 --- a/top/top.c +++ b/top/top.c @@ -1161,7 +1161,23 @@ static char *ioline (const char *prompt) { // weed out duplicates, including empty strings (top-of-stack)... for (i = 0, plin = anchor; ; i++) { - if (!STRCMP(plin->str, buf)) return buf; +#ifdef RECALL_FIXED + if (!STRCMP(plin->str, buf)) // if matched, retain original order + return buf; +#else + if (!STRCMP(plin->str, buf)) { // if matched, rearrange stack order + if (i > 1) { // but not null str or if already #2 + if (plin->bkw) // splice around this matched string + plin->bkw->fwd = plin->fwd; // if older exists link to newer + plin->fwd->bkw = plin->bkw; // newer linked to older or NULL + anchor->bkw->fwd = plin; // stick matched on top of former #2 + plin->bkw = anchor->bkw; // keep empty string at top-of-stack + plin->fwd = anchor; // then prepare to be the 2nd banana + anchor->bkw = plin; // by sliding us in below the anchor + } + return buf; + } +#endif if (!plin->bkw) break; // let i equal total stacked strings plin = plin->bkw; // ( with plin representing bottom ) } diff --git a/top/top.h b/top/top.h index d7fe8ff6..ca88e8bb 100644 --- a/top/top.h +++ b/top/top.h @@ -45,6 +45,7 @@ //#define PRETEND4CPUS /* pretend we're smp with 4 ticsers (sic) */ //#define PRETENDNOCAP /* use a terminal without essential caps */ //#define RCFILE_NOERR /* rcfile errs silently default, vs. fatal */ +//#define RECALL_FIXED /* don't reorder saved strings if recalled */ //#define RMAN_IGNORED /* don't consider auto right margin glitch */ //#define SCROLLVAR_NO /* disable intra-column horizontal scroll */ //#define STRINGCASENO /* case insenstive compare/locate versions */ @@ -597,6 +598,9 @@ typedef struct WIN_t { #if defined(ATEOJ_RPTHSH) && defined(OFF_HST_HASH) # error 'ATEOJ_RPTHSH' conflicts with 'OFF_HST_HASH' #endif +#if defined(RECALL_FIXED) && defined(TERMIOS_ONLY) +# error 'RECALL_FIXED' conflicts with 'TERMIOS_ONLY' +#endif #if (LRGBUFSIZ < SCREENMAX) # error 'LRGBUFSIZ' must NOT be less than 'SCREENMAX' #endif