The world's most popular open source database
00001 /* $NetBSD: el.h,v 1.16 2003/10/18 23:48:42 christos Exp $ */ 00002 00003 /*- 00004 * Copyright (c) 1992, 1993 00005 * The Regents of the University of California. All rights reserved. 00006 * 00007 * This code is derived from software contributed to Berkeley by 00008 * Christos Zoulas of Cornell University. 00009 * 00010 * Redistribution and use in source and binary forms, with or without 00011 * modification, are permitted provided that the following conditions 00012 * are met: 00013 * 1. Redistributions of source code must retain the above copyright 00014 * notice, this list of conditions and the following disclaimer. 00015 * 2. Redistributions in binary form must reproduce the above copyright 00016 * notice, this list of conditions and the following disclaimer in the 00017 * documentation and/or other materials provided with the distribution. 00018 * 3. Neither the name of the University nor the names of its contributors 00019 * may be used to endorse or promote products derived from this software 00020 * without specific prior written permission. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 00023 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00024 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00025 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 00026 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00027 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00028 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00029 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00031 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00032 * SUCH DAMAGE. 00033 * 00034 * @(#)el.h 8.1 (Berkeley) 6/4/93 00035 */ 00036 00037 /* 00038 * el.h: Internal structures. 00039 */ 00040 #ifndef _h_el 00041 #define _h_el 00042 /* 00043 * Local defaults 00044 */ 00045 #define KSHVI 00046 #define VIDEFAULT 00047 #define ANCHOR 00048 00049 #include <stdio.h> 00050 #include <sys/types.h> 00051 00052 #define EL_BUFSIZ 1024 /* Maximum line size */ 00053 00054 #define HANDLE_SIGNALS 0x01 00055 #define NO_TTY 0x02 00056 #define EDIT_DISABLED 0x04 00057 #define UNBUFFERED 0x08 00058 00059 typedef int bool_t; /* True or not */ 00060 00061 typedef unsigned char el_action_t; /* Index to command array */ 00062 00063 typedef struct coord_t { /* Position on the screen */ 00064 int h; 00065 int v; 00066 } coord_t; 00067 00068 typedef struct el_line_t { 00069 char *buffer; /* Input line */ 00070 char *cursor; /* Cursor position */ 00071 char *lastchar; /* Last character */ 00072 const char *limit; /* Max position */ 00073 } el_line_t; 00074 00075 /* 00076 * Editor state 00077 */ 00078 typedef struct el_state_t { 00079 int inputmode; /* What mode are we in? */ 00080 int doingarg; /* Are we getting an argument? */ 00081 int argument; /* Numeric argument */ 00082 int metanext; /* Is the next char a meta char */ 00083 el_action_t lastcmd; /* Previous command */ 00084 el_action_t thiscmd; /* this command */ 00085 char thisch; /* char that generated it */ 00086 } el_state_t; 00087 00088 /* 00089 * Until we come up with something better... 00090 */ 00091 #define el_strdup(a) strdup(a) 00092 #define el_malloc(a) malloc(a) 00093 #define el_realloc(a,b) realloc(a, b) 00094 #define el_free(a) free(a) 00095 00096 #include "tty.h" 00097 #include "prompt.h" 00098 #include "key.h" 00099 #include "el_term.h" 00100 #include "refresh.h" 00101 #include "chared.h" 00102 #include "common.h" 00103 #include "search.h" 00104 #include "hist.h" 00105 #include "map.h" 00106 #include "parse.h" 00107 #include "sig.h" 00108 #include "help.h" 00109 #include "read.h" 00110 00111 struct editline { 00112 char *el_prog; /* the program name */ 00113 FILE *el_outfile; /* Stdio stuff */ 00114 FILE *el_errfile; /* Stdio stuff */ 00115 int el_infd; /* Input file descriptor */ 00116 int el_flags; /* Various flags. */ 00117 coord_t el_cursor; /* Cursor location */ 00118 char **el_display; /* Real screen image = what is there */ 00119 char **el_vdisplay; /* Virtual screen image = what we see */ 00120 void *el_data; /* Client data */ 00121 el_line_t el_line; /* The current line information */ 00122 el_state_t el_state; /* Current editor state */ 00123 el_term_t el_term; /* Terminal dependent stuff */ 00124 el_tty_t el_tty; /* Tty dependent stuff */ 00125 el_refresh_t el_refresh; /* Refresh stuff */ 00126 el_prompt_t el_prompt; /* Prompt stuff */ 00127 el_prompt_t el_rprompt; /* Prompt stuff */ 00128 el_chared_t el_chared; /* Characted editor stuff */ 00129 el_map_t el_map; /* Key mapping stuff */ 00130 el_key_t el_key; /* Key binding stuff */ 00131 el_history_t el_history; /* History stuff */ 00132 el_search_t el_search; /* Search stuff */ 00133 el_signal_t el_signal; /* Signal handling stuff */ 00134 el_read_t el_read; /* Character reading stuff */ 00135 }; 00136 00137 protected int el_editmode(EditLine *, int, const char **); 00138 00139 #ifdef DEBUG 00140 #define EL_ABORT(a) do { \ 00141 fprintf(el->el_errfile, "%s, %d: ", \ 00142 __FILE__, __LINE__); \ 00143 fprintf a; \ 00144 abort(); \ 00145 } while( /*CONSTCOND*/0); 00146 #else 00147 #define EL_ABORT(a) abort() 00148 #endif 00149 #endif /* _h_el */
1.4.7

