home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / D / CLISP / CLISPSRC.TAR / clisp-1995-01-01 / src / readline / history.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-03-16  |  5.5 KB  |  140 lines

  1. /* history.h -- changed by Bruno Haible, 16 March 1993 */
  2.  
  3. /* History.h -- the names of functions that you can call in history. */
  4.  
  5. #ifndef _HISTORY_H_
  6. #define _HISTORY_H_
  7.  
  8. #ifndef RL
  9. /* For prototypes:  extern int foo RL((int x, int y)); */
  10. #ifdef __STDC__
  11. #define RL(args) args
  12. #else
  13. #define RL(args) ()
  14. #endif
  15. #endif
  16.  
  17. /* The structure used to store a history entry. */
  18. typedef struct _hist_entry {
  19.   char *line;
  20.   void *data;
  21. } HIST_ENTRY;
  22.  
  23. /* For convenience only.  You set this when interpreting history commands.
  24.    It is the logical offset of the first history element. */
  25. extern int history_base;
  26.  
  27. /* Begin a session in which the history functions might be used.  This
  28.    just initializes the interactive variables. */
  29. extern void using_history RL((void));
  30.  
  31. /* Place STRING at the end of the history list.
  32.    The associated data field (if any) is set to NULL. */
  33. extern void add_history RL((char* string));
  34.  
  35. /* Returns the number which says what history element we are now
  36.    looking at.  */
  37. extern int where_history RL((void));
  38.   
  39. /* Set the position in the history list to POS. */
  40. extern int history_set_pos RL((int pos));
  41.  
  42. /* Search for STRING in the history list, starting at POS, an
  43.    absolute index into the list.  DIR, if negative, says to search
  44.    backwards from POS, else forwards.
  45.    Returns the absolute index of the history element where STRING
  46.    was found, or -1 otherwise. */
  47. extern int history_search_pos RL((char* string, int dir, int pos));
  48.  
  49. /* A reasonably useless function, only here for completeness.  WHICH
  50.    is the magic number that tells us which element to delete.  The
  51.    elements are numbered from 0. */
  52. extern HIST_ENTRY *remove_history RL((int which));
  53.  
  54. /* Stifle the history list, remembering only MAX number of entries. */
  55. extern void stifle_history RL((int max));
  56.  
  57. /* Stop stifling the history.  This returns the previous amount the
  58.    history was stifled by.  The value is positive if the history was
  59.    stifled, negative if it wasn't. */
  60. extern int unstifle_history RL((void));
  61.  
  62. /* Add the contents of FILENAME to the history list, a line at a time.
  63.    If FILENAME is NULL, then read from ~/.history.  Returns 0 if
  64.    successful, or errno if not. */
  65. extern int read_history RL((char* filename));
  66.  
  67. /* Read a range of lines from FILENAME, adding them to the history list.
  68.    Start reading at the FROM'th line and end at the TO'th.  If FROM
  69.    is zero, start at the beginning.  If TO is less than FROM, read
  70.    until the end of the file.  If FILENAME is NULL, then read from
  71.    ~/.history.  Returns 0 if successful, or errno if not. */
  72. extern int read_history_range RL((char* filename, int from, int to));
  73.  
  74. /* Append the current history to FILENAME.  If FILENAME is NULL,
  75.    then append the history list to ~/.history.  Values returned
  76.    are as in read_history ().  */
  77. extern int write_history RL((char* filename));
  78.  
  79. /* Append NELEMENT entries to FILENAME.  The entries appended are from
  80.    the end of the list minus NELEMENTs up to the end of the list. */
  81. extern int append_history RL((int nelements, char* filename));
  82.  
  83. /* Make the history entry at WHICH have LINE and DATA.  This returns
  84.    the old entry so you can dispose of the data.  In the case of an
  85.    invalid WHICH, a NULL pointer is returned. */
  86. extern HIST_ENTRY *replace_history_entry RL((int which, char* line, void* data));
  87.  
  88. /* Return the history entry at the current position, as determined by
  89.    history_offset.  If there is no entry there, return a NULL pointer. */
  90. extern HIST_ENTRY *current_history RL((void));
  91.  
  92. /* Back up history_offset to the previous history entry, and return
  93.    a pointer to that entry.  If there is no previous entry, return
  94.    a NULL pointer. */
  95. extern HIST_ENTRY *previous_history RL((void));
  96.  
  97. /* Move history_offset forward to the next item in the input_history,
  98.    and return the a pointer to that entry.  If there is no next entry,
  99.    return a NULL pointer. */
  100. extern HIST_ENTRY *next_history RL((void));
  101.  
  102. /* Return a NULL terminated array of HIST_ENTRY which is the current input
  103.    history.  Element 0 of this list is the beginning of time.  If there
  104.    is no history, return NULL. */
  105. extern HIST_ENTRY **history_list RL((void));
  106.  
  107. /* Search the history for STRING, starting at history_offset.
  108.    If DIRECTION < 0, then the search is through previous entries,
  109.    else through subsequent.  If the string is found, then
  110.    current_history () is the history entry, and the value of this function
  111.    is the offset in the line of that history entry that the string was
  112.    found in.  Otherwise, nothing is changed, and a -1 is returned. */
  113. extern int history_search RL((char* string, int direction));
  114.  
  115. /* Expand the string STRING, placing the result into OUTPUT, a pointer
  116.    to a string.  Returns:
  117.  
  118.    0) If no expansions took place (or, if the only change in
  119.       the text was the de-slashifying of the history expansion
  120.       character)
  121.    1) If expansions did take place
  122.   -1) If there was an error in expansion.
  123.  
  124.   If an error ocurred in expansion, then OUTPUT contains a descriptive
  125.   error message. */
  126. extern int history_expand RL((char* string, char** output));
  127.  
  128. /* Extract a string segment consisting of the FIRST through LAST
  129.    arguments present in STRING.  Arguments are broken up as in
  130.    the shell. */
  131. extern char *history_arg_extract RL((int first, int last, char* string));
  132.  
  133. /* Return the number of bytes that the primary history entries are using.
  134.    This just adds up the lengths of the_history->lines. */
  135. extern int history_total_bytes RL((void));
  136.  
  137. extern int history_search_prefix RL((char* string, int direction));
  138.  
  139. #endif /* _HISTORY_H_ */
  140.