Fix texinfo-3.12 problems:
[deliverable/binutils-gdb.git] / readline / history.h
CommitLineData
d60d9f65
SS
1/* History.h -- the names of functions that you can call in history. */
2/* Copyright (C) 1989, 1992 Free Software Foundation, Inc.
3
4 This file contains the GNU History Library (the Library), a set of
5 routines for managing the text of previously typed lines.
6
7 The Library is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 1, or (at your option)
10 any later version.
11
12 The Library is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
16
17 The GNU General Public License is often shipped with GNU software, and
18 is generally kept in a file called COPYING or LICENSE. If you do not
19 have a copy of the license, write to the Free Software Foundation,
20 675 Mass Ave, Cambridge, MA 02139, USA. */
21
22#ifndef _HISTORY_H_
23#define _HISTORY_H_
24
c862e87b
JM
25#ifdef __cplusplus
26extern "C" {
27#endif
28
29#if defined READLINE_LIBRARY
30# include "rlstdc.h"
31#else
32# include <readline/rlstdc.h>
33#endif
34
d60d9f65
SS
35#if !defined (_FUNCTION_DEF)
36# define _FUNCTION_DEF
37typedef int Function ();
38typedef void VFunction ();
39typedef char *CPFunction ();
40typedef char **CPPFunction ();
41#endif
42
c862e87b
JM
43#ifdef __STDC__
44typedef void *histdata_t;
45#else
46typedef char *histdata_t;
47#endif
48
d60d9f65
SS
49/* The structure used to store a history entry. */
50typedef struct _hist_entry {
51 char *line;
c862e87b 52 histdata_t data;
d60d9f65
SS
53} HIST_ENTRY;
54
55/* A structure used to pass the current state of the history stuff around. */
56typedef struct _hist_state {
57 HIST_ENTRY **entries; /* Pointer to the entries themselves. */
58 int offset; /* The location pointer within this array. */
59 int length; /* Number of elements within this array. */
60 int size; /* Number of slots allocated to this array. */
61 int flags;
62} HISTORY_STATE;
63
64/* Flag values for the `flags' member of HISTORY_STATE. */
65#define HS_STIFLED 0x01
66
67/* Initialization and state management. */
68
69/* Begin a session in which the history functions might be used. This
70 just initializes the interactive variables. */
c862e87b 71extern void using_history __P((void));
d60d9f65
SS
72
73/* Return the current HISTORY_STATE of the history. */
c862e87b 74extern HISTORY_STATE *history_get_history_state __P((void));
d60d9f65
SS
75
76/* Set the state of the current history array to STATE. */
c862e87b 77extern void history_set_history_state __P((HISTORY_STATE *));
d60d9f65
SS
78
79/* Manage the history list. */
80
81/* Place STRING at the end of the history list.
82 The associated data field (if any) is set to NULL. */
c862e87b 83extern void add_history __P((char *));
d60d9f65
SS
84
85/* A reasonably useless function, only here for completeness. WHICH
86 is the magic number that tells us which element to delete. The
87 elements are numbered from 0. */
c862e87b 88extern HIST_ENTRY *remove_history __P((int));
d60d9f65
SS
89
90/* Make the history entry at WHICH have LINE and DATA. This returns
91 the old entry so you can dispose of the data. In the case of an
92 invalid WHICH, a NULL pointer is returned. */
c862e87b 93extern HIST_ENTRY *replace_history_entry __P((int, char *, histdata_t));
d60d9f65
SS
94
95/* Clear the history list and start over. */
c862e87b 96extern void clear_history __P((void));
d60d9f65
SS
97
98/* Stifle the history list, remembering only MAX number of entries. */
c862e87b 99extern void stifle_history __P((int));
d60d9f65
SS
100
101/* Stop stifling the history. This returns the previous amount the
102 history was stifled by. The value is positive if the history was
103 stifled, negative if it wasn't. */
c862e87b 104extern int unstifle_history __P((void));
d60d9f65
SS
105
106/* Return 1 if the history is stifled, 0 if it is not. */
c862e87b 107extern int history_is_stifled __P((void));
d60d9f65
SS
108
109/* Information about the history list. */
110
111/* Return a NULL terminated array of HIST_ENTRY which is the current input
112 history. Element 0 of this list is the beginning of time. If there
113 is no history, return NULL. */
c862e87b 114extern HIST_ENTRY **history_list __P((void));
d60d9f65
SS
115
116/* Returns the number which says what history element we are now
117 looking at. */
c862e87b 118extern int where_history __P((void));
d60d9f65
SS
119
120/* Return the history entry at the current position, as determined by
121 history_offset. If there is no entry there, return a NULL pointer. */
c862e87b 122HIST_ENTRY *current_history __P((void));
d60d9f65
SS
123
124/* Return the history entry which is logically at OFFSET in the history
125 array. OFFSET is relative to history_base. */
c862e87b 126extern HIST_ENTRY *history_get __P((int));
d60d9f65
SS
127
128/* Return the number of bytes that the primary history entries are using.
129 This just adds up the lengths of the_history->lines. */
c862e87b 130extern int history_total_bytes __P((void));
d60d9f65
SS
131
132/* Moving around the history list. */
133
134/* Set the position in the history list to POS. */
c862e87b 135int history_set_pos __P((int));
d60d9f65
SS
136
137/* Back up history_offset to the previous history entry, and return
138 a pointer to that entry. If there is no previous entry, return
139 a NULL pointer. */
c862e87b 140extern HIST_ENTRY *previous_history __P((void));
d60d9f65
SS
141
142/* Move history_offset forward to the next item in the input_history,
143 and return the a pointer to that entry. If there is no next entry,
144 return a NULL pointer. */
c862e87b 145extern HIST_ENTRY *next_history __P((void));
d60d9f65
SS
146
147/* Searching the history list. */
148
149/* Search the history for STRING, starting at history_offset.
150 If DIRECTION < 0, then the search is through previous entries,
151 else through subsequent. If the string is found, then
152 current_history () is the history entry, and the value of this function
153 is the offset in the line of that history entry that the string was
154 found in. Otherwise, nothing is changed, and a -1 is returned. */
c862e87b 155extern int history_search __P((char *, int));
d60d9f65
SS
156
157/* Search the history for STRING, starting at history_offset.
c862e87b
JM
158 The search is anchored: matching lines must begin with string.
159 DIRECTION is as in history_search(). */
160extern int history_search_prefix __P((char *, int));
d60d9f65
SS
161
162/* Search for STRING in the history list, starting at POS, an
163 absolute index into the list. DIR, if negative, says to search
164 backwards from POS, else forwards.
165 Returns the absolute index of the history element where STRING
166 was found, or -1 otherwise. */
c862e87b 167extern int history_search_pos __P((char *, int, int));
d60d9f65
SS
168
169/* Managing the history file. */
170
171/* Add the contents of FILENAME to the history list, a line at a time.
172 If FILENAME is NULL, then read from ~/.history. Returns 0 if
173 successful, or errno if not. */
c862e87b 174extern int read_history __P((char *));
d60d9f65
SS
175
176/* Read a range of lines from FILENAME, adding them to the history list.
177 Start reading at the FROM'th line and end at the TO'th. If FROM
178 is zero, start at the beginning. If TO is less than FROM, read
179 until the end of the file. If FILENAME is NULL, then read from
180 ~/.history. Returns 0 if successful, or errno if not. */
c862e87b 181extern int read_history_range __P((char *, int, int));
d60d9f65
SS
182
183/* Write the current history to FILENAME. If FILENAME is NULL,
184 then write the history list to ~/.history. Values returned
185 are as in read_history (). */
c862e87b 186extern int write_history __P((char *));
d60d9f65
SS
187
188/* Append NELEMENT entries to FILENAME. The entries appended are from
189 the end of the list minus NELEMENTs up to the end of the list. */
c862e87b 190int append_history __P((int, char *));
d60d9f65
SS
191
192/* Truncate the history file, leaving only the last NLINES lines. */
c862e87b 193extern int history_truncate_file __P((char *, int));
d60d9f65
SS
194
195/* History expansion. */
196
197/* Expand the string STRING, placing the result into OUTPUT, a pointer
198 to a string. Returns:
199
200 0) If no expansions took place (or, if the only change in
201 the text was the de-slashifying of the history expansion
202 character)
203 1) If expansions did take place
204 -1) If there was an error in expansion.
205 2) If the returned line should just be printed.
206
207 If an error ocurred in expansion, then OUTPUT contains a descriptive
208 error message. */
c862e87b 209extern int history_expand __P((char *, char **));
d60d9f65
SS
210
211/* Extract a string segment consisting of the FIRST through LAST
212 arguments present in STRING. Arguments are broken up as in
213 the shell. */
c862e87b 214extern char *history_arg_extract __P((int, int, char *));
d60d9f65
SS
215
216/* Return the text of the history event beginning at the current
c862e87b
JM
217 offset into STRING. Pass STRING with *INDEX equal to the
218 history_expansion_char that begins this specification.
219 DELIMITING_QUOTE is a character that is allowed to end the string
220 specification for what to search for in addition to the normal
221 characters `:', ` ', `\t', `\n', and sometimes `?'. */
222extern char *get_history_event __P((char *, int *, int));
d60d9f65
SS
223
224/* Return an array of tokens, much as the shell might. The tokens are
225 parsed out of STRING. */
c862e87b 226extern char **history_tokenize __P((char *));
d60d9f65
SS
227
228/* Exported history variables. */
229extern int history_base;
230extern int history_length;
231extern int max_input_history;
232extern char history_expansion_char;
233extern char history_subst_char;
234extern char history_comment_char;
235extern char *history_no_expand_chars;
236extern char *history_search_delimiter_chars;
237extern int history_quotes_inhibit_expansion;
238
239/* If set, this function is called to decide whether or not a particular
240 history expansion should be treated as a special case for the calling
241 application and not expanded. */
242extern Function *history_inhibit_expansion_function;
243
c862e87b
JM
244#ifdef __cplusplus
245}
246#endif
247
d60d9f65 248#endif /* !_HISTORY_H_ */
This page took 0.043634 seconds and 4 git commands to generate.