/* Move down to the next history line. */ int rl_get_next_history (int count, int key) { HIST_ENTRY *temp; if (count < 0) return (rl_get_previous_history (-count, key)); if (count == 0) return 0; rl_maybe_replace_line (); /* either not saved by rl_newline or at end of line, so set appropriately. */ if (_rl_history_saved_point == -1 && (rl_point || rl_end)) _rl_history_saved_point = (rl_point == rl_end) ? -1 : rl_point; temp = (HIST_ENTRY *)NULL; while (count) { temp = next_history (); if (!temp) break; --count; } if (temp == 0) rl_maybe_unsave_line (); else { rl_replace_from_history (temp, 0); _rl_history_set_point (); } return 0; }
/* Meta-> goes to the end of the history. (The current line). */ int rl_end_of_history (int count, int key) { rl_maybe_replace_line (); using_history (); rl_maybe_unsave_line (); return 0; }
/* Get the previous item out of our interactive history, making it the current line. If there is no previous history, just ding. */ int rl_get_previous_history (int count, int key) { HIST_ENTRY *old_temp, *temp; if (count < 0) return (rl_get_next_history (-count, key)); if (count == 0 || history_list () == 0) return 0; /* either not saved by rl_newline or at end of line, so set appropriately. */ if (_rl_history_saved_point == -1 && (rl_point || rl_end)) _rl_history_saved_point = (rl_point == rl_end) ? -1 : rl_point; /* If we don't have a line saved, then save this one. */ rl_maybe_save_line (); /* If the current line has changed, save the changes. */ rl_maybe_replace_line (); temp = old_temp = (HIST_ENTRY *)NULL; while (count) { temp = previous_history (); if (temp == 0) break; old_temp = temp; --count; } /* If there was a large argument, and we moved back to the start of the history, that is not an error. So use the last value found. */ if (!temp && old_temp) temp = old_temp; if (temp == 0) { rl_maybe_unsave_line (); rl_ding (); } else { rl_replace_from_history (temp, 0); _rl_history_set_point (); } return 0; }
int maybe_replace_line () { return rl_maybe_replace_line (); }