--- readline-egg.c 2014-12-11 01:57:27.105532179 -0700 +++ readline-egg.c.new 2014-12-11 01:41:21.633164305 -0700 @@ -63,7 +63,7 @@ return pos + 1; while (pos >= 0) { - open++; + ++open; pos = gnu_readline_skip(pos, open_key, close_key); } @@ -90,7 +90,7 @@ } // Delays, but returns early if key press occurs -void gnu_readline_timid_delay(ms) +void gnu_readline_timid_delay(int ms) { struct pollfd pfd; @@ -268,7 +268,7 @@ h = history_get(history_base + history_length - 1); if (NULL == h || 0 != strcmp(h->line, gnu_readline_buf)) { add_history(gnu_readline_buf); - gnu_history_newlines++; + ++gnu_history_newlines; } } @@ -288,3 +288,24 @@ rl_free_line_state(); rl_cleanup_after_signal(); } + +char *gnu_history_get_line(int offset) +{ + HIST_ENTRY *entry = NULL; + if (offset < 0) + entry = previous_history(); + else if (offset > 0) + entry = next_history(); + else + entry = current_history(); + + // did the operation succeed? + if (entry == NULL) + return NULL; // no + return entry->line; // yes +} + +int gnu_history_list_length() +{ + return history_length; +}