diff options
author | Chet Ramey <chet.ramey@case.edu> | 2014-02-26 10:31:21 -0500 |
---|---|---|
committer | Chet Ramey <chet.ramey@case.edu> | 2014-02-26 10:31:21 -0500 |
commit | 7628b745a813aac53586b640da056a975f1c443e (patch) | |
tree | f27689da65e9873cd0a77f64f334814989ef5478 /misc.c | |
parent | 3fede80c7ae9d396a98137ec8e7188a27c327e96 (diff) | |
download | readline-6.3.tar.gz |
Readline-6.3 distribution sources and documentationreadline-6.3
Diffstat (limited to 'misc.c')
-rw-r--r-- | misc.c | 39 |
1 files changed, 38 insertions, 1 deletions
@@ -1,6 +1,6 @@ /* misc.c -- miscellaneous bindable readline functions. */ -/* Copyright (C) 1987-2009 Free Software Foundation, Inc. +/* Copyright (C) 1987-2012 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. @@ -56,6 +56,8 @@ static int rl_digit_loop PARAMS((void)); static void _rl_history_set_point PARAMS((void)); +extern int history_offset; + /* Forward declarations used in this file */ void _rl_free_history_entry PARAMS((HIST_ENTRY *)); @@ -483,6 +485,37 @@ _rl_revert_all_lines () xfree (lbuf); } +/* 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 + should not be called while editing is active. */ +void +rl_clear_history () +{ + HIST_ENTRY **hlist, *hent; + register int i; + UNDO_LIST *ul, *saved_undo_list; + + saved_undo_list = rl_undo_list; + hlist = history_list (); /* direct pointer, not copy */ + + for (i = 0; i < history_length; i++) + { + hent = hlist[i]; + if (ul = (UNDO_LIST *)hent->data) + { + if (ul == saved_undo_list) + saved_undo_list = 0; + _rl_free_undo_list (ul); + hent->data = 0; + } + _rl_free_history_entry (hent); + } + + history_offset = history_length = 0; + rl_undo_list = saved_undo_list; /* should be NULL */ +} + /* **************************************************************** */ /* */ /* History Commands */ @@ -623,6 +656,10 @@ rl_emacs_editing_mode (count, key) rl_editing_mode = emacs_mode; _rl_set_insert_mode (RL_IM_INSERT, 1); /* emacs mode default is insert mode */ _rl_keymap = emacs_standard_keymap; + + if (_rl_show_mode_in_prompt) + _rl_reset_prompt (); + return 0; } |