📄 history.html
字号:
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="history.html#SEC17"> >> </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><H3> 2.3.1 Initializing History and State Management </H3><!--docid::SEC10::--><P>This section describes functions used to initialize and managethe state of the History library when you want to use the historyfunctions in your program.</P><P><A NAME="IDX2"></A><DL><DT><U>Function:</U> void <B>using_history</B> <I>(void)</I><DD>Begin a session in which the history functions might be used. Thisinitializes the interactive variables.</DL></P><P><A NAME="IDX3"></A><DL><DT><U>Function:</U> HISTORY_STATE * <B>history_get_history_state</B> <I>(void)</I><DD>Return a structure describing the current state of the input history.</DL></P><P><A NAME="IDX4"></A><DL><DT><U>Function:</U> void <B>history_set_history_state</B> <I>(HISTORY_STATE *state)</I><DD>Set the state of the history list according to <VAR>state</VAR>.</DL></P><P><A NAME="History List Management"></A><HR SIZE="6"><A NAME="SEC11"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="history.html#SEC10"> < </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="history.html#SEC12"> > </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="history.html#SEC12"> << </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="history.html#SEC9"> Up </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="history.html#SEC17"> >> </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><H3> 2.3.2 History List Management </H3><!--docid::SEC11::--><P>These functions manage individual entries on the history list, or setparameters managing the list itself.</P><P><A NAME="IDX5"></A><DL><DT><U>Function:</U> void <B>add_history</B> <I>(const char *string)</I><DD>Place <VAR>string</VAR> at the end of the history list. The associated datafield (if any) is set to <CODE>NULL</CODE>.</DL></P><P><A NAME="IDX6"></A><DL><DT><U>Function:</U> HIST_ENTRY * <B>remove_history</B> <I>(int which)</I><DD>Remove history entry at offset <VAR>which</VAR> from the history. Theremoved element is returned so you can free the line, data,and containing structure.</DL></P><P><A NAME="IDX7"></A><DL><DT><U>Function:</U> HIST_ENTRY * <B>replace_history_entry</B> <I>(int which, const char *line, histdata_t data)</I><DD>Make the history entry at offset <VAR>which</VAR> have <VAR>line</VAR> and <VAR>data</VAR>.This returns the old entry so you can dispose of the data. In the caseof an invalid <VAR>which</VAR>, a <CODE>NULL</CODE> pointer is returned.</DL></P><P><A NAME="IDX8"></A><DL><DT><U>Function:</U> void <B>clear_history</B> <I>(void)</I><DD>Clear the history list by deleting all the entries.</DL></P><P><A NAME="IDX9"></A><DL><DT><U>Function:</U> void <B>stifle_history</B> <I>(int max)</I><DD>Stifle the history list, remembering only the last <VAR>max</VAR> entries.</DL></P><P><A NAME="IDX10"></A><DL><DT><U>Function:</U> int <B>unstifle_history</B> <I>(void)</I><DD>Stop stifling the history. This returns the previously-setmaximum number of history entries (as set by <CODE>stifle_history()</CODE>).The value is positive if the history wasstifled, negative if it wasn't.</DL></P><P><A NAME="IDX11"></A><DL><DT><U>Function:</U> int <B>history_is_stifled</B> <I>(void)</I><DD>Returns non-zero if the history is stifled, zero if it is not.</DL></P><P><A NAME="Information About the History List"></A><HR SIZE="6"><A NAME="SEC12"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="history.html#SEC11"> < </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="history.html#SEC13"> > </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="history.html#SEC13"> << </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="history.html#SEC9"> Up </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="history.html#SEC17"> >> </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><H3> 2.3.3 Information About the History List </H3><!--docid::SEC12::--><P>These functions return information about the entire history list orindividual list entries.</P><P><A NAME="IDX12"></A><DL><DT><U>Function:</U> HIST_ENTRY ** <B>history_list</B> <I>(void)</I><DD>Return a <CODE>NULL</CODE> terminated array of <CODE>HIST_ENTRY *</CODE> which is thecurrent input history. Element 0 of this list is the beginning of time.If there is no history, return <CODE>NULL</CODE>.</DL></P><P><A NAME="IDX13"></A><DL><DT><U>Function:</U> int <B>where_history</B> <I>(void)</I><DD>Returns the offset of the current history element.</DL></P><P><A NAME="IDX14"></A><DL><DT><U>Function:</U> HIST_ENTRY * <B>current_history</B> <I>(void)</I><DD>Return the history entry at the current position, as determined by<CODE>where_history()</CODE>. If there is no entry there, return a <CODE>NULL</CODE>pointer.</DL></P><P><A NAME="IDX15"></A><DL><DT><U>Function:</U> HIST_ENTRY * <B>history_get</B> <I>(int offset)</I><DD>Return the history entry at position <VAR>offset</VAR>, starting from<CODE>history_base</CODE> (see section <A HREF="history.html#SEC17">2.4 History Variables</A>).If there is no entry there, or if <VAR>offset</VAR>is greater than the history length, return a <CODE>NULL</CODE> pointer.</DL></P><P><A NAME="IDX16"></A><DL><DT><U>Function:</U> int <B>history_total_bytes</B> <I>(void)</I><DD>Return the number of bytes that the primary history entries are using.This function returns the sum of the lengths of all the lines in thehistory.</DL></P><P><A NAME="Moving Around the History List"></A><HR SIZE="6"><A NAME="SEC13"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="history.html#SEC12"> < </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="history.html#SEC14"> > </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="history.html#SEC14"> << </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="history.html#SEC9"> Up </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="history.html#SEC17"> >> </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><H3> 2.3.4 Moving Around the History List </H3><!--docid::SEC13::--><P>These functions allow the current index into the history list to beset or changed.</P><P><A NAME="IDX17"></A><DL><DT><U>Function:</U> int <B>history_set_pos</B> <I>(int pos)</I><DD>Set the current history offset to <VAR>pos</VAR>, an absolute indexinto the list.Returns 1 on success, 0 if <VAR>pos</VAR> is less than zero or greaterthan the number of history entries.</DL></P><P><A NAME="IDX18"></A><DL><DT><U>Function:</U> HIST_ENTRY * <B>previous_history</B> <I>(void)</I><DD>Back up the current history offset to the previous history entry, andreturn a pointer to that entry. If there is no previous entry, returna <CODE>NULL</CODE> pointer.</DL></P><P><A NAME="IDX19"></A><DL><DT><U>Function:</U> HIST_ENTRY * <B>next_history</B> <I>(void)</I><DD>Move the current history offset forward to the next history entry, andreturn the a pointer to that entry. If there is no next entry, returna <CODE>NULL</CODE> pointer.</DL></P><P><A NAME="Searching the History List"></A><HR SIZE="6"><A NAME="SEC14"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="history.html#SEC13"> < </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="history.html#SEC15"> > </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="history.html#SEC15"> << </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="history.html#SEC9"> Up </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="history.html#SEC17"> >> </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><H3> 2.3.5 Searching the History List </H3><!--docid::SEC14::--><P>These functions allow searching of the history list for entries containinga specific string. Searching may be performed both forward and backwardfrom the current history position. The search may be <EM>anchored</EM>,meaning that the string must match at the beginning of the history entry.<A NAME="IDX20"></A></P><P><A NAME="IDX21"></A><DL><DT><U>Function:</U> int <B>history_search</B> <I>(const char *string, int direction)</I><DD>Search the history for <VAR>string</VAR>, starting at the current history offset.If <VAR>direction</VAR> is less than 0, then the search is throughprevious entries, otherwise through subsequent entries.If <VAR>string</VAR> is found, thenthe current history index is set to that history entry, and the valuereturned is the offset in the line of the entry where<VAR>string</VAR> was found. Otherwise, nothing is changed, and a -1 isreturned.</DL></P><P><A NAME="IDX22"></A>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -