1 /*- 2 * Copyright (c) 1992, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Christos Zoulas of Cornell University. 7 * 8 * %sccs.include.redist.c% 9 * 10 * @(#)hist.h 8.1 (Berkeley) 06/04/93 11 */ 12 13 /* 14 * el.hist.c: History functions 15 */ 16 #ifndef _h_el_hist 17 #define _h_el_hist 18 19 #include "histedit.h" 20 21 typedef const HistEvent * (*hist_fun_t) __P((ptr_t, int, ...)); 22 23 typedef struct el_history_t { 24 char *buf; /* The history buffer */ 25 char *last; /* The last character */ 26 int eventno; /* Event we are looking for */ 27 ptr_t ref; /* Argument for history fcns */ 28 hist_fun_t fun; /* Event access */ 29 const HistEvent *ev; /* Event cookie */ 30 } el_history_t; 31 32 #define HIST_FUN(el, fn, arg) \ 33 ((((el)->el_history.ev = \ 34 (*(el)->el_history.fun)((el)->el_history.ref, fn, arg)) == NULL) ? \ 35 NULL : (el)->el_history.ev->str) 36 37 #define HIST_NEXT(el) HIST_FUN(el, H_NEXT, NULL) 38 #define HIST_FIRST(el) HIST_FUN(el, H_FIRST, NULL) 39 #define HIST_LAST(el) HIST_FUN(el, H_LAST, NULL) 40 #define HIST_PREV(el) HIST_FUN(el, H_PREV, NULL) 41 #define HIST_EVENT(el, num) HIST_FUN(el, H_EVENT, num) 42 43 protected int hist_init __P((EditLine *)); 44 protected void hist_end __P((EditLine *)); 45 protected el_action_t hist_get __P((EditLine *)); 46 protected int hist_set __P((EditLine *, hist_fun_t, ptr_t)); 47 protected int hist_list __P((EditLine *, int, char **)); 48 49 #endif /* _h_el_hist */ 50