1 /* GNUPLOT - gp_hist.h */ 2 3 /*[ 4 * Copyright 1999, 2004 Thomas Williams, Colin Kelley 5 * 6 * Permission to use, copy, and distribute this software and its 7 * documentation for any purpose with or without fee is hereby granted, 8 * provided that the above copyright notice appear in all copies and 9 * that both that copyright notice and this permission notice appear 10 * in supporting documentation. 11 * 12 * Permission to modify the software is granted, but not the right to 13 * distribute the complete modified source code. Modifications are to 14 * be distributed as patches to the released version. Permission to 15 * distribute binaries produced by compiling modified sources is granted, 16 * provided you 17 * 1. distribute the corresponding source modifications from the 18 * released version in the form of a patch file along with the binaries, 19 * 2. add special version identification to distinguish your version 20 * in addition to the base release version number, 21 * 3. provide your name and address as the primary contact for the 22 * support of your modified version, and 23 * 4. retain our contact information in regard to use of the base 24 * software. 25 * Permission to distribute the released version of the source code along 26 * with corresponding source modifications in the form of a patch file is 27 * granted with same provisions 2 through 4 for binary distributions. 28 * 29 * This software is provided "as is" without express or implied warranty 30 * to the extent permitted by applicable law. 31 ]*/ 32 33 #ifndef GNUPLOT_HISTORY_H 34 # define GNUPLOT_HISTORY_H 35 36 #include "syscfg.h" 37 38 #define HISTORY_SIZE 500 39 40 /* Variables of history.c needed by other modules: */ 41 42 extern int gnuplot_history_size; 43 extern TBOOLEAN history_quiet; 44 extern TBOOLEAN history_full; 45 46 /* GNU readline 47 */ 48 #if defined(HAVE_LIBREADLINE) 49 # include <readline/history.h> 50 51 52 #elif defined(HAVE_LIBEDITLINE) || defined(HAVE_WINEDITLINE) 53 /* NetBSD editline / WinEditLine 54 * (almost) compatible readline replacement 55 */ 56 # include <editline/readline.h> 57 58 59 #elif defined(READLINE) 60 /* gnuplot's built-in replacement history functions 61 */ 62 63 typedef void * histdata_t; 64 65 typedef struct hist { 66 char *line; 67 histdata_t data; 68 struct hist *prev; 69 struct hist *next; 70 } HIST_ENTRY; 71 72 extern int history_length; 73 extern int history_base; 74 75 void using_history(void); 76 void clear_history(void); 77 void add_history(char *line); 78 void read_history(char *); 79 int write_history(char *); 80 int where_history(void); 81 int history_set_pos(int offset); 82 HIST_ENTRY * history_get(int offset); 83 HIST_ENTRY * current_history(void); 84 HIST_ENTRY * previous_history(void); 85 HIST_ENTRY * next_history(void); 86 HIST_ENTRY * replace_history_entry(int which, const char *line, histdata_t data); 87 HIST_ENTRY * remove_history(int which); 88 histdata_t free_history_entry(HIST_ENTRY *histent); 89 int history_search(const char *string, int direction); 90 int history_search_prefix(const char *string, int direction); 91 #endif 92 93 94 #ifdef USE_READLINE 95 96 /* extra functions provided by history.c */ 97 98 int gp_read_history(const char *filename); 99 void write_history_n(const int, const char *, const char *); 100 const char *history_find(char *); 101 const char *history_find_by_number(int); 102 int history_find_all(char *); 103 104 #endif 105 106 #endif /* GNUPLOT_HISTORY_H */ 107