1*3e1db26aSLionel Sambuc /* $NetBSD: el.h,v 1.25 2011/07/29 23:44:44 christos Exp $ */ 2*3e1db26aSLionel Sambuc 3*3e1db26aSLionel Sambuc /*- 4*3e1db26aSLionel Sambuc * Copyright (c) 1992, 1993 5*3e1db26aSLionel Sambuc * The Regents of the University of California. All rights reserved. 6*3e1db26aSLionel Sambuc * 7*3e1db26aSLionel Sambuc * This code is derived from software contributed to Berkeley by 8*3e1db26aSLionel Sambuc * Christos Zoulas of Cornell University. 9*3e1db26aSLionel Sambuc * 10*3e1db26aSLionel Sambuc * Redistribution and use in source and binary forms, with or without 11*3e1db26aSLionel Sambuc * modification, are permitted provided that the following conditions 12*3e1db26aSLionel Sambuc * are met: 13*3e1db26aSLionel Sambuc * 1. Redistributions of source code must retain the above copyright 14*3e1db26aSLionel Sambuc * notice, this list of conditions and the following disclaimer. 15*3e1db26aSLionel Sambuc * 2. Redistributions in binary form must reproduce the above copyright 16*3e1db26aSLionel Sambuc * notice, this list of conditions and the following disclaimer in the 17*3e1db26aSLionel Sambuc * documentation and/or other materials provided with the distribution. 18*3e1db26aSLionel Sambuc * 3. Neither the name of the University nor the names of its contributors 19*3e1db26aSLionel Sambuc * may be used to endorse or promote products derived from this software 20*3e1db26aSLionel Sambuc * without specific prior written permission. 21*3e1db26aSLionel Sambuc * 22*3e1db26aSLionel Sambuc * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23*3e1db26aSLionel Sambuc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24*3e1db26aSLionel Sambuc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25*3e1db26aSLionel Sambuc * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26*3e1db26aSLionel Sambuc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27*3e1db26aSLionel Sambuc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28*3e1db26aSLionel Sambuc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29*3e1db26aSLionel Sambuc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30*3e1db26aSLionel Sambuc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31*3e1db26aSLionel Sambuc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32*3e1db26aSLionel Sambuc * SUCH DAMAGE. 33*3e1db26aSLionel Sambuc * 34*3e1db26aSLionel Sambuc * @(#)el.h 8.1 (Berkeley) 6/4/93 35*3e1db26aSLionel Sambuc */ 36*3e1db26aSLionel Sambuc 37*3e1db26aSLionel Sambuc /* 38*3e1db26aSLionel Sambuc * el.h: Internal structures. 39*3e1db26aSLionel Sambuc */ 40*3e1db26aSLionel Sambuc #ifndef _h_el 41*3e1db26aSLionel Sambuc #define _h_el 42*3e1db26aSLionel Sambuc /* 43*3e1db26aSLionel Sambuc * Local defaults 44*3e1db26aSLionel Sambuc */ 45*3e1db26aSLionel Sambuc #define KSHVI 46*3e1db26aSLionel Sambuc #define VIDEFAULT 47*3e1db26aSLionel Sambuc #define ANCHOR 48*3e1db26aSLionel Sambuc 49*3e1db26aSLionel Sambuc #include "histedit.h" 50*3e1db26aSLionel Sambuc #include "chartype.h" 51*3e1db26aSLionel Sambuc #include <stdio.h> 52*3e1db26aSLionel Sambuc #include <sys/types.h> 53*3e1db26aSLionel Sambuc 54*3e1db26aSLionel Sambuc #define EL_BUFSIZ ((size_t)1024) /* Maximum line size */ 55*3e1db26aSLionel Sambuc 56*3e1db26aSLionel Sambuc #define HANDLE_SIGNALS 0x01 57*3e1db26aSLionel Sambuc #define NO_TTY 0x02 58*3e1db26aSLionel Sambuc #define EDIT_DISABLED 0x04 59*3e1db26aSLionel Sambuc #define UNBUFFERED 0x08 60*3e1db26aSLionel Sambuc #define CHARSET_IS_UTF8 0x10 61*3e1db26aSLionel Sambuc #define IGNORE_EXTCHARS 0x20 /* Ignore characters read > 0xff */ 62*3e1db26aSLionel Sambuc #define NARROW_HISTORY 0x40 63*3e1db26aSLionel Sambuc #define NARROW_READ 0x80 64*3e1db26aSLionel Sambuc 65*3e1db26aSLionel Sambuc typedef int bool_t; /* True or not */ 66*3e1db26aSLionel Sambuc 67*3e1db26aSLionel Sambuc typedef unsigned char el_action_t; /* Index to command array */ 68*3e1db26aSLionel Sambuc 69*3e1db26aSLionel Sambuc typedef struct coord_t { /* Position on the screen */ 70*3e1db26aSLionel Sambuc int h; 71*3e1db26aSLionel Sambuc int v; 72*3e1db26aSLionel Sambuc } coord_t; 73*3e1db26aSLionel Sambuc 74*3e1db26aSLionel Sambuc typedef struct el_line_t { 75*3e1db26aSLionel Sambuc Char *buffer; /* Input line */ 76*3e1db26aSLionel Sambuc Char *cursor; /* Cursor position */ 77*3e1db26aSLionel Sambuc Char *lastchar; /* Last character */ 78*3e1db26aSLionel Sambuc const Char *limit; /* Max position */ 79*3e1db26aSLionel Sambuc } el_line_t; 80*3e1db26aSLionel Sambuc 81*3e1db26aSLionel Sambuc /* 82*3e1db26aSLionel Sambuc * Editor state 83*3e1db26aSLionel Sambuc */ 84*3e1db26aSLionel Sambuc typedef struct el_state_t { 85*3e1db26aSLionel Sambuc int inputmode; /* What mode are we in? */ 86*3e1db26aSLionel Sambuc int doingarg; /* Are we getting an argument? */ 87*3e1db26aSLionel Sambuc int argument; /* Numeric argument */ 88*3e1db26aSLionel Sambuc int metanext; /* Is the next char a meta char */ 89*3e1db26aSLionel Sambuc el_action_t lastcmd; /* Previous command */ 90*3e1db26aSLionel Sambuc el_action_t thiscmd; /* this command */ 91*3e1db26aSLionel Sambuc Char thisch; /* char that generated it */ 92*3e1db26aSLionel Sambuc } el_state_t; 93*3e1db26aSLionel Sambuc 94*3e1db26aSLionel Sambuc /* 95*3e1db26aSLionel Sambuc * Until we come up with something better... 96*3e1db26aSLionel Sambuc */ 97*3e1db26aSLionel Sambuc #define el_malloc(a) malloc(a) 98*3e1db26aSLionel Sambuc #define el_realloc(a,b) realloc(a, b) 99*3e1db26aSLionel Sambuc #define el_free(a) free(a) 100*3e1db26aSLionel Sambuc 101*3e1db26aSLionel Sambuc #include "tty.h" 102*3e1db26aSLionel Sambuc #include "prompt.h" 103*3e1db26aSLionel Sambuc #include "keymacro.h" 104*3e1db26aSLionel Sambuc #include "terminal.h" 105*3e1db26aSLionel Sambuc #include "refresh.h" 106*3e1db26aSLionel Sambuc #include "chared.h" 107*3e1db26aSLionel Sambuc #include "common.h" 108*3e1db26aSLionel Sambuc #include "search.h" 109*3e1db26aSLionel Sambuc #include "hist.h" 110*3e1db26aSLionel Sambuc #include "map.h" 111*3e1db26aSLionel Sambuc #include "parse.h" 112*3e1db26aSLionel Sambuc #include "sig.h" 113*3e1db26aSLionel Sambuc #include "help.h" 114*3e1db26aSLionel Sambuc #include "read.h" 115*3e1db26aSLionel Sambuc 116*3e1db26aSLionel Sambuc struct editline { 117*3e1db26aSLionel Sambuc Char *el_prog; /* the program name */ 118*3e1db26aSLionel Sambuc FILE *el_infile; /* Stdio stuff */ 119*3e1db26aSLionel Sambuc FILE *el_outfile; /* Stdio stuff */ 120*3e1db26aSLionel Sambuc FILE *el_errfile; /* Stdio stuff */ 121*3e1db26aSLionel Sambuc int el_infd; /* Input file descriptor */ 122*3e1db26aSLionel Sambuc int el_outfd; /* Output file descriptor */ 123*3e1db26aSLionel Sambuc int el_errfd; /* Error file descriptor */ 124*3e1db26aSLionel Sambuc int el_flags; /* Various flags. */ 125*3e1db26aSLionel Sambuc int el_errno; /* Local copy of errno */ 126*3e1db26aSLionel Sambuc coord_t el_cursor; /* Cursor location */ 127*3e1db26aSLionel Sambuc Char **el_display; /* Real screen image = what is there */ 128*3e1db26aSLionel Sambuc Char **el_vdisplay; /* Virtual screen image = what we see */ 129*3e1db26aSLionel Sambuc void *el_data; /* Client data */ 130*3e1db26aSLionel Sambuc el_line_t el_line; /* The current line information */ 131*3e1db26aSLionel Sambuc el_state_t el_state; /* Current editor state */ 132*3e1db26aSLionel Sambuc el_terminal_t el_terminal; /* Terminal dependent stuff */ 133*3e1db26aSLionel Sambuc el_tty_t el_tty; /* Tty dependent stuff */ 134*3e1db26aSLionel Sambuc el_refresh_t el_refresh; /* Refresh stuff */ 135*3e1db26aSLionel Sambuc el_prompt_t el_prompt; /* Prompt stuff */ 136*3e1db26aSLionel Sambuc el_prompt_t el_rprompt; /* Prompt stuff */ 137*3e1db26aSLionel Sambuc el_chared_t el_chared; /* Characted editor stuff */ 138*3e1db26aSLionel Sambuc el_map_t el_map; /* Key mapping stuff */ 139*3e1db26aSLionel Sambuc el_keymacro_t el_keymacro; /* Key binding stuff */ 140*3e1db26aSLionel Sambuc el_history_t el_history; /* History stuff */ 141*3e1db26aSLionel Sambuc el_search_t el_search; /* Search stuff */ 142*3e1db26aSLionel Sambuc el_signal_t el_signal; /* Signal handling stuff */ 143*3e1db26aSLionel Sambuc el_read_t el_read; /* Character reading stuff */ 144*3e1db26aSLionel Sambuc #ifdef WIDECHAR 145*3e1db26aSLionel Sambuc ct_buffer_t el_scratch; /* Scratch conversion buffer */ 146*3e1db26aSLionel Sambuc ct_buffer_t el_lgcyconv; /* Buffer for legacy wrappers */ 147*3e1db26aSLionel Sambuc LineInfo el_lgcylinfo; /* Legacy LineInfo buffer */ 148*3e1db26aSLionel Sambuc #endif 149*3e1db26aSLionel Sambuc }; 150*3e1db26aSLionel Sambuc 151*3e1db26aSLionel Sambuc protected int el_editmode(EditLine *, int, const Char **); 152*3e1db26aSLionel Sambuc 153*3e1db26aSLionel Sambuc #ifdef DEBUG 154*3e1db26aSLionel Sambuc #define EL_ABORT(a) do { \ 155*3e1db26aSLionel Sambuc fprintf(el->el_errfile, "%s, %d: ", \ 156*3e1db26aSLionel Sambuc __FILE__, __LINE__); \ 157*3e1db26aSLionel Sambuc fprintf a; \ 158*3e1db26aSLionel Sambuc abort(); \ 159*3e1db26aSLionel Sambuc } while( /*CONSTCOND*/0); 160*3e1db26aSLionel Sambuc #else 161*3e1db26aSLionel Sambuc #define EL_ABORT(a) abort() 162*3e1db26aSLionel Sambuc #endif 163*3e1db26aSLionel Sambuc #endif /* _h_el */ 164