📄 history.html
字号:
character. The default value is 0.</DL></P><P><A NAME="IDX43"></A><DL><DT><U>Variable:</U> rl_linebuf_func_t * <B>history_inhibit_expansion_function</B><DD>This should be set to the address of a function that takes two arguments:a <CODE>char *</CODE> (<VAR>string</VAR>)and an <CODE>int</CODE> index into that string (<VAR>i</VAR>).It should return a non-zero value if the history expansion starting at<VAR>string[i]</VAR> should not be performed; zero if the expansion shouldbe done.It is intended for use by applications like Bash that use the historyexpansion character for additional purposes.By default, this variable is set to <CODE>NULL</CODE>.</DL></P><P><A NAME="History Programming Example"></A><HR SIZE="6"><A NAME="SEC18"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="history.html#SEC17"> < </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="history.html#SEC19"> > </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[ << ]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="history.html#SEC6"> Up </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="history.html#SEC19"> >> </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="history.html#SEC_Top">Top</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="history.html#SEC_Contents">Contents</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="history.html#SEC19">Index</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="history.html#SEC_About"> ? </A>]</TD></TR></TABLE><H2> 2.5 History Programming Example </H2><!--docid::SEC18::--><P>The following program demonstrates simple use of the GNU History Library.</P><P><TABLE><tr><td> </td><td class=smallexample><FONT SIZE=-1><pre>#include <stdio.h>#include <readline/history.h>main (argc, argv) int argc; char **argv;{ char line[1024], *t; int len, done = 0; line[0] = 0; using_history (); while (!done) { printf ("history$ "); fflush (stdout); t = fgets (line, sizeof (line) - 1, stdin); if (t && *t) { len = strlen (t); if (t[len - 1] == '\n') t[len - 1] = '\0'; } if (!t) strcpy (line, "quit"); if (line[0]) { char *expansion; int result; result = history_expand (line, &expansion); if (result) fprintf (stderr, "%s\n", expansion); if (result < 0 || result == 2) { free (expansion); continue; } add_history (expansion); strncpy (line, expansion, sizeof (line) - 1); free (expansion); } if (strcmp (line, "quit") == 0) done = 1; else if (strcmp (line, "save") == 0) write_history ("history_file"); else if (strcmp (line, "read") == 0) read_history ("history_file"); else if (strcmp (line, "list") == 0) { register HIST_ENTRY **the_list; register int i; the_list = history_list (); if (the_list) for (i = 0; the_list[i]; i++) printf ("%d: %s\n", i + history_base, the_list[i]->line); } else if (strncmp (line, "delete", 6) == 0) { int which; if ((sscanf (line + 6, "%d", &which)) == 1) { HIST_ENTRY *entry = remove_history (which); if (!entry) fprintf (stderr, "No such entry %d\n", which); else { free (entry->line); free (entry); } } else { fprintf (stderr, "non-numeric arg given to `delete'\n"); } } }}</FONT></pre></td></tr></table></P><P><A NAME="Concept Index"></A><HR SIZE="6"><A NAME="SEC19"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="history.html#SEC18"> < </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="history.html#SEC20"> > </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="history.html#SEC6"> << </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="history.html#SEC_Top"> Up </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="history.html#SEC20"> >> </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="history.html#SEC_Top">Top</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="history.html#SEC_Contents">Contents</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="history.html#SEC19">Index</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="history.html#SEC_About"> ? </A>]</TD></TR></TABLE><H1> A. Concept Index </H1><!--docid::SEC19::--><table><tr><th valign=top>Jump to: </th><td><A HREF="history.html#cp_A" style="text-decoration:none"><b>A</b></A> <A HREF="history.html#cp_E" style="text-decoration:none"><b>E</b></A> <A HREF="history.html#cp_H" style="text-decoration:none"><b>H</b></A> </td></tr></table><br><P></P><TABLE border=0><TR><TD></TD><TH ALIGN=LEFT>Index Entry</TH><TH ALIGN=LEFT> Section</TH></TR><TR><TD COLSPAN=3> <HR></TD></TR><TR><TH><A NAME="cp_A"></A>A</TH><TD></TD><TD></TD></TR><TR><TD></TD><TD valign=top><A HREF="history.html#IDX20">anchored search</A></TD><TD valign=top><A HREF="history.html#SEC14">2.3.5 Searching the History List</A></TD></TR><TR><TD COLSPAN=3> <HR></TD></TR><TR><TH><A NAME="cp_E"></A>E</TH><TD></TD><TD></TD></TR><TR><TD></TD><TD valign=top><A HREF="history.html#SEC3">event designators</A></TD><TD valign=top><A HREF="history.html#SEC3">1.1.1 Event Designators</A></TD></TR><TR><TD COLSPAN=3> <HR></TD></TR><TR><TH><A NAME="cp_H"></A>H</TH><TD></TD><TD></TD></TR><TR><TD></TD><TD valign=top><A HREF="history.html#IDX1">history events</A></TD><TD valign=top><A HREF="history.html#SEC3">1.1.1 Event Designators</A></TD></TR><TR><TD></TD><TD valign=top><A HREF="history.html#SEC2">history expansion</A></TD><TD valign=top><A HREF="history.html#SEC2">1.1 History Expansion</A></TD></TR><TR><TD></TD><TD valign=top><A HREF="history.html#SEC14">History Searching</A></TD><TD valign=top><A HREF="history.html#SEC14">2.3.5 Searching the History List</A></TD></TR><TR><TD COLSPAN=3> <HR></TD></TR></TABLE><P></P><table><tr><th valign=top>Jump to: </th><td><A HREF="history.html#cp_A" style="text-decoration:none"><b>A</b></A> <A HREF="history.html#cp_E" style="text-decoration:none"><b>E</b></A> <A HREF="history.html#cp_H" style="text-decoration:none"><b>H</b></A> </td></tr></table><br><P><A NAME="Function and Variable Index"></A><HR SIZE="6"><A NAME="SEC20"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="history.html#SEC19"> < </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[ > ]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[ << ]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="history.html#SEC_Top"> Up </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[ >> ]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="history.html#SEC_Top">Top</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="history.html#SEC_Contents">Contents</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="history.html#SEC19">Index</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="history.html#SEC_About"> ? </A>]</TD></TR></TABLE><H1> B. Function and Variable Index </H1><!--docid::SEC20::--><table><tr><th valign=top>Jump to: </th><td><A HREF="history.html#vr_A" style="text-decoration:none"><b>A</b></A> <A HREF="history.html#vr_C" style="text-decoration:none"><b>C</b></A> <A HREF="history.html#vr_G" style="text-decoration:none"><b>G</b></A> <A HREF="history.html#vr_H" style="text-decoration:none"><b>H</b></A> <A HREF="history.html#vr_N" style="text-decoration:none"><b>N</b></A> <A HREF="history.html#vr_P" style="text-decoration:none"><b>P</b></A> <A HREF="history.html#vr_R" style="text-decoration:none"><b>R</b></A> <A HREF="history.html#vr_S" style="text-decoration:none"><b>S</b></A> <A HREF="history.html#vr_U" style="text-decoration:none"><b>U</b></A> <A HREF="history.html#vr_W" style="text-decoration:none"><b>W</b></A> </td></tr></table><br><P></P><TABLE border=0><TR><TD></TD><TH ALIGN=LEFT>Index Entry</TH><TH ALIGN=LEFT> Section</TH></TR><TR><TD COLSPAN=3> <HR></TD></TR><TR><TH><A NAME="vr_A"></A>A</TH><TD></TD><TD></TD></TR><TR><TD></TD><TD valign=top><A HREF="history.html#IDX5"><CODE>add_history</CODE></A></TD><TD valign=top><A HREF="history.html#SEC11">2.3.2 History List Management</A></TD></TR><TR><TD></TD><TD valign=top><A HREF="history.html#IDX27"><CODE>append_history</CODE></A></TD><TD valign=top><A HREF="history.html#SEC15">2.3.6 Managing the History File</A></TD></TR><TR><TD COLSPAN=3> <HR></TD></TR><TR><TH><A NAME="vr_C"></A>C</TH><TD></TD><TD></TD></TR><TR><TD></TD><TD valign=top><A HREF="history.html#IDX8"><CODE>clear_history</CODE></A></TD><TD valign=top><A HREF="history.html#SEC11">2.3.2 History List Management</A></TD></TR><TR><TD></TD><TD valign=top><A HREF="history.html#IDX14"><CODE>current_history</CODE></A></TD><TD valign=top><A HREF="history.html#SEC12">2.3.3 Information About the History List</A></TD></TR><TR><TD COLSPAN=3> <HR></TD></TR><TR><TH><A NAME="vr_G"></A>G</TH><TD></TD><TD></TD></TR><TR><TD></TD><TD valign=top><A HREF="history.html#IDX30"><CODE>get_history_event</CODE></A></TD><TD valign=top><A HREF="history.html#SEC16">2.3.7 History Expansion</A></TD></TR><TR><TD COLSPAN=3> <HR></TD></TR><TR><TH><A NAME="vr_H"></A>H</TH><TD></TD><TD></TD></TR><TR><TD></TD><TD valign=top><A HREF="history.html#IDX32"><CODE>history_arg_extract</CODE></A></TD><TD valign=top><A HREF="history.html#SEC16">2.3.7 History Expansion</A></TD></TR><TR><TD></TD><TD valign=top><A HREF="history.html#IDX33"><CODE>history_base</CODE></A></TD><TD valign=top><A HREF="history.html#SEC17">2.4 History Variables</A></TD></TR><TR><TD></TD><TD valign=top><A HREF="history.html#IDX38"><CODE>history_comment_char</CODE></A></TD><TD valign=top><A HREF="history.html#SEC17">2.4 History Variables</A></TD></TR><TR><TD></TD><TD valign=top><A HREF="history.html#IDX29"><CODE>history_expand</CODE></A></TD><TD valign=top><A HREF="history.html#SEC16">2.3.7 History Expansion</A></TD></TR><TR><TD></TD><TD valign=top><A HREF="history.html#IDX36"><CODE>history_expansion_char</CODE></A></TD><TD valign=top><A HREF="history.html#SEC17">2.4 History Variables</A></TD></TR><TR><TD></TD><TD valign=top><A HREF="history.html#IDX15"><CODE>history_get</CODE></A></TD><TD valign=top><A HREF="history.html#SEC12">2.3.3 Information About the History List</A></TD></TR><TR><TD></TD><TD valign=top><A HREF="history.html#IDX3"><CODE>history_get_history_state</CODE></A></TD><TD valign=top><A HREF="history.html#SEC10">2.3.1 Initializing History and State Management</A></TD></TR><TR><TD></TD><TD valign=top><A HREF="history.html#IDX43"><CODE>history_inhibit_expansion_function</CODE></A></TD><TD valign=top><A HREF="history.html#SEC17">2.4 History Variables</A></TD></TR><TR><TD></TD><TD valign=top><A HREF="history.html#IDX11"><CODE>history_is_stifled</CODE></A></TD><TD valign=top><A HREF="history.html#SEC11">2.3.2 History List Management</A></TD></TR><TR><TD></TD><TD valign=top><A HREF="history.html#IDX34"><CODE>history_length</CODE></A></TD><TD valign=top><A HREF="history.html#SEC17">2.4 History Variables</A></TD></TR><TR><TD></TD><TD valign=top><A HREF="history.html#IDX12"><CODE>history_list</CODE></A></TD><TD valign=top><A HREF="history.html#SEC12">2.3.3 Information About the History List</A></TD></TR><TR><TD></TD><TD valign=top><A HREF="history.html#IDX35"><CODE>history_max_entries</CODE></A></TD><TD valign=top><A HREF="history.html#SEC17">2.4 History Variables</A></TD></TR><TR><TD></TD><TD valign=top><A HREF="history.html#IDX40"><CODE>history_no_expand_chars</CODE></A></TD><TD valign=top><A HREF="history.html#SEC17">2.4 History Variables</A></TD></TR><TR><TD></TD><TD valign=top><A HREF="history.html#IDX42"><CODE>history_quotes_inhibit_expansion</CODE></A></TD><TD valign=top><A HREF="history.html#SEC17">2.4 History Variables</A></TD></TR><TR><TD></TD><TD valign=top><A HREF="history.html#IDX21"><CODE>history_search</CODE></A></TD><TD valign=top><A HREF="history.html#SEC14">2.3.5 Searching the History List</A></TD></TR><TR><TD></TD><TD valign=top><A HREF="history.html#IDX41"><CODE>history_search_delimiter_chars</CODE></A></TD><TD valign=top><A HREF="history.html#SEC17">2.4 History Variables</A></TD></TR><TR><TD></TD><TD valign=top><A HREF="history.html#IDX23"><CODE>history_search_pos</CODE></A></TD><TD valign=top><A HREF="history.html#SEC14">2.3.5 Searching the History List</A></TD></TR><TR><TD></TD><TD valign=top><A HREF="history.html#IDX22"><CODE>history_search_prefix</CODE></A></TD><TD valign=top><A HREF="history.html#SEC14">2.3.5 Searching the History List</A></TD></TR><TR><TD></TD><TD valign=top><A HREF="history.html#IDX4"><CODE>history_set_history_state</CODE></A></TD><TD valign=top><A HREF="history.html#SEC10">2.3.1 Initializing History and State Management</A></TD></TR><TR><TD></TD><TD valign=top><A HREF="history.html#IDX17"><CODE>history_set_pos</CODE></A></TD><TD valign=top><A HREF="history.html#SEC13">2.3.4 Moving Around the History List</A></TD></TR><TR><TD></TD><TD valign=top><A HREF="history.html#IDX37"><CODE>history_subst_char</CODE></A></TD><TD valign=top><A HREF="history.html#SEC17">2.4 History Variables</A></TD></TR><TR><TD></TD><TD valign=top><A HREF="history.html#IDX31"><CODE>history_tokenize</CODE></A></TD><TD valign=top><A HREF="history.html#SEC16">2.3.7 History Expansion</A></TD></TR><TR><TD></TD><TD valign=top><A HREF="history.html#IDX16"><CODE>history_total_bytes</CODE></A></TD><TD valign=top><A HREF="history.html#SEC12">2.3.3 Information About the History List</A></TD></TR><TR><TD></TD><TD valign=top><A HREF="history.html#IDX28"><CODE>history_truncate_file</CODE></A></TD><TD valign=top><A HREF="history.html#SEC15">2.3.6 Managing the History File</A></TD></TR><TR><TD></TD><TD valign=top><A HREF="history.html#IDX39"><CODE>history_word_delimiters</CODE></A></TD><TD valign=top><A HREF="history.html#SEC17">2.4 History Variables</A></TD></TR><TR><TD COLSPAN=3> <HR></TD></TR><TR><TH><A NAME="vr_N"></A>N</TH><TD></TD><TD></TD></TR><TR><TD></TD><TD valign=top><A HREF="history.html#IDX19"><CODE>next_history</CODE></A></TD><TD valign=top><A HREF="history.html#SEC13">2.3.4 Moving Around the History List</A></TD></TR><TR><TD COLSPAN=3> <HR></TD></TR><TR><TH><A NAME="vr_P"></A>P</TH><TD></TD><TD></TD></TR><TR><TD></TD><TD valign=top><A HREF="history.html#IDX18"><CODE>previous_history</CODE></A></TD><TD valign=top><A HREF="history.html#SEC13">2.3.4 Moving Around the History List</A></TD></TR><TR><TD COLSPAN=3> <HR></TD></TR><TR><TH><A NAME="vr_R"></A>R</TH><TD></TD><TD></TD></TR><TR><TD></TD><TD valign=top><A HREF="history.html#IDX24"><CODE>read_history</CODE></A></TD><TD valign=top><A HREF="history.html#SEC15">2.3.6 Managing the History File</A></TD></TR><TR><TD></TD><TD valign=top><A HREF="history.html#IDX25"><CODE>read_history_range</CODE></A></TD><TD valign=top><A HREF="history.html#SEC15">2.3.6 Managing the History File</A></TD></TR><TR><TD></TD><TD valign=top><A HREF="history.html#IDX6"><CODE>remove_history</CODE></A></TD><TD valign=top><A HREF="history.html#SEC11">2.3.2 History List Management</A></TD></TR><TR><TD></TD><TD valign=top><A HREF="history.html#IDX7"><CODE>replace_history_entry</CODE></A></TD><TD valign=top><A HREF="history.html#SEC11">2.3.2 History List Management</A></TD></TR><TR><TD COLSPAN=3> <HR></TD></TR><TR><TH><A NAME="vr_S"></A>S</TH><TD></TD><TD></TD></TR><TR><TD></TD><TD valign=top><A HREF="history.html#IDX9"><CODE>stifle_history</CODE></A></TD><TD valign=top><A HREF="history.html#SEC11">2.3.2 History List Management</A></TD></TR><TR><TD COLSPAN=3> <HR></TD></TR><TR><TH><A NAME="vr_U"></A>U</TH><TD></TD><TD></TD></TR><TR><TD></TD><TD valign=top><A HREF="history.html#IDX10"><CODE>unstifle_history</CODE></A></TD><TD valign=top><A HREF="history.html#SEC11">2.3.2 History List Management</A></TD></TR><TR><TD></TD><TD valign=top><A HREF="history.html#IDX2"><CODE>using_history</CODE></A></TD><TD valign=top><A HREF="history.html#SEC10">2.3.1 Initializing History and State Management</A></TD></TR><TR><TD COLSPAN=3> <HR></TD></TR><TR><TH><A NAME="vr_W"></A>W</TH><TD></TD><TD></TD></TR><TR><TD></TD><TD valign=top><A HREF="history.html#IDX13"><CODE>where_history
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -