diff options
| author | Chet Ramey <chet.ramey@case.edu> | 2020-06-15 16:10:22 -0400 |
|---|---|---|
| committer | Chet Ramey <chet.ramey@case.edu> | 2020-06-15 16:10:22 -0400 |
| commit | 576f19e34c32c9ad1bab3c4a130e7027cd3fd9de (patch) | |
| tree | 20b5f0aab6d689754a634944c4e51de61afbd837 /misc.c | |
| parent | c5ad6be530f5c1daf64a2d20df4baba9f6b57aa4 (diff) | |
| download | readline-576f19e34c32c9ad1bab3c4a130e7027cd3fd9de.tar.gz | |
readline-8.1-alpha releasereadline-8.1-alpha
Diffstat (limited to 'misc.c')
| -rw-r--r-- | misc.c | 63 |
1 files changed, 58 insertions, 5 deletions
@@ -1,6 +1,6 @@ /* misc.c -- miscellaneous bindable readline functions. */ -/* Copyright (C) 1987-2017 Free Software Foundation, Inc. +/* Copyright (C) 1987-2019 Free Software Foundation, Inc. This file is part of the GNU Readline Library (Readline), a library for reading lines of text with interactive input and history editing. @@ -138,9 +138,7 @@ _rl_arg_dispatch (_rl_arg_cxt cxt, int c) } else { - RL_SETSTATE(RL_STATE_MOREINPUT); - key = rl_read_key (); - RL_UNSETSTATE(RL_STATE_MOREINPUT); + key = _rl_bracketed_read_key (); rl_restore_prompt (); rl_clear_message (); RL_UNSETSTATE(RL_STATE_NUMERICARG); @@ -435,7 +433,7 @@ rl_replace_from_history (HIST_ENTRY *entry, int flags) intended to be called while actively editing, and the current line is not assumed to have been added to the history list. */ void -_rl_revert_all_lines (void) +_rl_revert_previous_lines (void) { int hpos; HIST_ENTRY *entry; @@ -479,6 +477,19 @@ _rl_revert_all_lines (void) xfree (lbuf); } +/* Revert all lines in the history by making sure we are at the end of the + history before calling _rl_revert_previous_lines() */ +void +_rl_revert_all_lines (void) +{ + int pos; + + pos = where_history (); + using_history (); + _rl_revert_previous_lines (); + history_set_pos (pos); +} + /* Free the history list, including private readline data and take care of pointer aliases to history data. Resets rl_undo_list if it points to an UNDO_LIST * saved as some history entry's data member. This @@ -626,6 +637,48 @@ rl_get_previous_history (int count, int key) return 0; } +/* The equivalent of the Korn shell C-o operate-and-get-next-history-line + editing command. */ + +/* This could stand to be global to the readline library */ +static rl_hook_func_t *_rl_saved_internal_startup_hook = 0; +static int saved_history_logical_offset = -1; + +#define HISTORY_FULL() (history_is_stifled () && history_length >= history_max_entries) + +static int +set_saved_history () +{ + int absolute_offset, count; + + if (saved_history_logical_offset >= 0) + { + absolute_offset = saved_history_logical_offset - history_base; + count = where_history () - absolute_offset; + rl_get_previous_history (count, 0); + } + saved_history_logical_offset = -1; + _rl_internal_startup_hook = _rl_saved_internal_startup_hook; + + return (0); +} + +int +rl_operate_and_get_next (count, c) + int count, c; +{ + /* Accept the current line. */ + rl_newline (1, c); + + saved_history_logical_offset = rl_explicit_arg ? count : where_history () + history_base + 1; + + + _rl_saved_internal_startup_hook = _rl_internal_startup_hook; + _rl_internal_startup_hook = set_saved_history; + + return 0; +} + /* **************************************************************** */ /* */ /* Editing Modes */ |
