home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pyth_os2.zip / python-1.0.2 / readline / history.h < prev    next >
C/C++ Source or Header  |  1991-07-09  |  5KB  |  122 lines

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