00001 // @(#)root/editline:$Id: hist.h 30194 2009-09-16 12:19:46Z axel $ 00002 // Author: Mary-Louise Gill, 2009 00003 00004 /************************************************************************* 00005 * Copyright (C) 1995-2009, Rene Brun and Fons Rademakers. * 00006 * All rights reserved. * 00007 * * 00008 * For the licensing terms see $ROOTSYS/LICENSE. * 00009 * For the list of contributors see $ROOTSYS/README/CREDITS. * 00010 *************************************************************************/ 00011 00012 /* $NetBSD: hist.fH,v 1.6 2001/01/10 07:45:41 jdolecek Exp $ */ 00013 00014 /*- 00015 * Copyright (c) 1992, 1993 00016 * The Regents of the University of California. All rights reserved. 00017 * 00018 * This code is derived from software contributed to Berkeley by 00019 * Christos Zoulas of Cornell University. 00020 * 00021 * Redistribution and use in source and binary forms, with or without 00022 * modification, are permitted provided that the following conditions 00023 * are met: 00024 * 1. Redistributions of source code must retain the above copyright 00025 * notice, this list of conditions and the following disclaimer. 00026 * 2. Redistributions in binary form must reproduce the above copyright 00027 * notice, this list of conditions and the following disclaimer in the 00028 * documentation and/or other materials provided with the distribution. 00029 * 3. Neither the name of the University nor the names of its contributors 00030 * may be used to endorse or promote products derived from this software 00031 * without specific prior written permission. 00032 * 00033 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 00034 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00035 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00036 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 00037 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00038 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00039 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00040 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00041 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00042 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00043 * SUCH DAMAGE. 00044 */ 00045 00046 /* 00047 * el.hist.c: History_t functions 00048 */ 00049 #ifndef _h_el_hist 00050 #define _h_el_hist 00051 00052 #include "histedit.h" 00053 00054 typedef int (*HistFun_t)(ptr_t, HistEvent_t*, int, ...); 00055 00056 typedef struct ElHistory_t { 00057 char* fBuf; /* The history buffer */ 00058 size_t fSz; /* Size of history buffer */ 00059 char* fLast; /* The last character */ 00060 int fEventNo; /* Event we are looking for */ 00061 ptr_t fRef; /* Argument for history fcns */ 00062 HistFun_t fFun; /* Event access */ 00063 HistEvent_t fEv; /* Event cookie */ 00064 } ElHistory_t; 00065 00066 #define HIST_FUN(el, fn, arg) \ 00067 ((((*(el)->fHistory.fFun)((el)->fHistory.fRef, &(el)->fHistory.fEv, \ 00068 fn, arg)) == -1) ? NULL : (el)->fHistory.fEv.fStr) 00069 00070 #define HIST_NEXT(el) HIST_FUN(el, H_NEXT, NULL) 00071 #define HIST_FIRST(el) HIST_FUN(el, H_FIRST, NULL) 00072 #define HIST_LAST(el) HIST_FUN(el, H_LAST, NULL) 00073 #define HIST_PREV(el) HIST_FUN(el, H_PREV, NULL) 00074 #define HIST_EVENT(el, num) HIST_FUN(el, H_EVENT, num) 00075 #define HIST_LOAD(el, fname) HIST_FUN(el, H_LOAD fname) 00076 #define HIST_SAVE(el, fname) HIST_FUN(el, H_SAVE fname) 00077 00078 el_protected int hist_init(EditLine_t*); 00079 el_protected void hist_end(EditLine_t*); 00080 el_protected ElAction_t hist_get(EditLine_t*); 00081 el_protected int hist_set(EditLine_t *, HistFun_t, ptr_t); 00082 el_protected int hist_list(EditLine_t*, int, const char**); 00083 el_protected int hist_enlargebuf(EditLine_t *, size_t, size_t); 00084 00085 #endif /* _h_el_hist */