11573Srgrimes/*- 21573Srgrimes * Copyright (c) 1992, 1993 31573Srgrimes * The Regents of the University of California. All rights reserved. 41573Srgrimes * 51573Srgrimes * This code is derived from software contributed to Berkeley by 61573Srgrimes * Christos Zoulas of Cornell University. 71573Srgrimes * 81573Srgrimes * Redistribution and use in source and binary forms, with or without 91573Srgrimes * modification, are permitted provided that the following conditions 101573Srgrimes * are met: 111573Srgrimes * 1. Redistributions of source code must retain the above copyright 121573Srgrimes * notice, this list of conditions and the following disclaimer. 131573Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 141573Srgrimes * notice, this list of conditions and the following disclaimer in the 151573Srgrimes * documentation and/or other materials provided with the distribution. 16148834Sstefanf * 3. Neither the name of the University nor the names of its contributors 171573Srgrimes * may be used to endorse or promote products derived from this software 181573Srgrimes * without specific prior written permission. 191573Srgrimes * 201573Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 211573Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 221573Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 231573Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 241573Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 251573Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 261573Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 271573Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 281573Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 291573Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 301573Srgrimes * SUCH DAMAGE. 311573Srgrimes * 321573Srgrimes * @(#)el.h 8.1 (Berkeley) 6/4/93 33170511Sstefanf * $NetBSD: el.h,v 1.17 2006/12/15 22:13:33 christos Exp $ 3484260Sobrien * $FreeBSD$ 351573Srgrimes */ 361573Srgrimes 371573Srgrimes/* 381573Srgrimes * el.h: Internal structures. 391573Srgrimes */ 401573Srgrimes#ifndef _h_el 4184260Sobrien#define _h_el 421573Srgrimes/* 431573Srgrimes * Local defaults 441573Srgrimes */ 4584260Sobrien#define KSHVI 4684260Sobrien#define VIDEFAULT 4784260Sobrien#define ANCHOR 481573Srgrimes 491573Srgrimes#include <stdio.h> 501573Srgrimes#include <sys/types.h> 511573Srgrimes 5284260Sobrien#define EL_BUFSIZ 1024 /* Maximum line size */ 531573Srgrimes 54148834Sstefanf#define HANDLE_SIGNALS 0x01 55148834Sstefanf#define NO_TTY 0x02 56148834Sstefanf#define EDIT_DISABLED 0x04 57148834Sstefanf#define UNBUFFERED 0x08 581573Srgrimes 591573Srgrimestypedef int bool_t; /* True or not */ 601573Srgrimes 611573Srgrimestypedef unsigned char el_action_t; /* Index to command array */ 621573Srgrimes 631573Srgrimestypedef struct coord_t { /* Position on the screen */ 6484260Sobrien int h; 6584260Sobrien int v; 661573Srgrimes} coord_t; 671573Srgrimes 681573Srgrimestypedef struct el_line_t { 6984260Sobrien char *buffer; /* Input line */ 7084260Sobrien char *cursor; /* Cursor position */ 7184260Sobrien char *lastchar; /* Last character */ 72148834Sstefanf const char *limit; /* Max position */ 731573Srgrimes} el_line_t; 741573Srgrimes 751573Srgrimes/* 761573Srgrimes * Editor state 771573Srgrimes */ 781573Srgrimestypedef struct el_state_t { 7984260Sobrien int inputmode; /* What mode are we in? */ 8084260Sobrien int doingarg; /* Are we getting an argument? */ 8184260Sobrien int argument; /* Numeric argument */ 8284260Sobrien int metanext; /* Is the next char a meta char */ 8384260Sobrien el_action_t lastcmd; /* Previous command */ 84148834Sstefanf el_action_t thiscmd; /* this command */ 85148834Sstefanf char thisch; /* char that generated it */ 861573Srgrimes} el_state_t; 871573Srgrimes 881573Srgrimes/* 891573Srgrimes * Until we come up with something better... 901573Srgrimes */ 91148834Sstefanf#define el_strdup(a) strdup(a) 9284260Sobrien#define el_malloc(a) malloc(a) 9384260Sobrien#define el_realloc(a,b) realloc(a, b) 9484260Sobrien#define el_free(a) free(a) 951573Srgrimes 961573Srgrimes#include "tty.h" 971573Srgrimes#include "prompt.h" 981573Srgrimes#include "key.h" 991573Srgrimes#include "term.h" 1001573Srgrimes#include "refresh.h" 1011573Srgrimes#include "chared.h" 1021573Srgrimes#include "common.h" 1031573Srgrimes#include "search.h" 1041573Srgrimes#include "hist.h" 1051573Srgrimes#include "map.h" 1061573Srgrimes#include "parse.h" 1071573Srgrimes#include "sig.h" 1081573Srgrimes#include "help.h" 109148834Sstefanf#include "read.h" 1101573Srgrimes 1111573Srgrimesstruct editline { 11284260Sobrien char *el_prog; /* the program name */ 113170511Sstefanf FILE *el_infile; /* Stdio stuff */ 11484260Sobrien FILE *el_outfile; /* Stdio stuff */ 11584260Sobrien FILE *el_errfile; /* Stdio stuff */ 11684260Sobrien int el_infd; /* Input file descriptor */ 11784260Sobrien int el_flags; /* Various flags. */ 118238378Spfg int el_errno; /* Local copy of errno */ 11984260Sobrien coord_t el_cursor; /* Cursor location */ 12084260Sobrien char **el_display; /* Real screen image = what is there */ 12184260Sobrien char **el_vdisplay; /* Virtual screen image = what we see */ 122148834Sstefanf void *el_data; /* Client data */ 12384260Sobrien el_line_t el_line; /* The current line information */ 12484260Sobrien el_state_t el_state; /* Current editor state */ 12584260Sobrien el_term_t el_term; /* Terminal dependent stuff */ 12684260Sobrien el_tty_t el_tty; /* Tty dependent stuff */ 12784260Sobrien el_refresh_t el_refresh; /* Refresh stuff */ 12884260Sobrien el_prompt_t el_prompt; /* Prompt stuff */ 12984260Sobrien el_prompt_t el_rprompt; /* Prompt stuff */ 13084260Sobrien el_chared_t el_chared; /* Characted editor stuff */ 13184260Sobrien el_map_t el_map; /* Key mapping stuff */ 13284260Sobrien el_key_t el_key; /* Key binding stuff */ 13384260Sobrien el_history_t el_history; /* History stuff */ 13484260Sobrien el_search_t el_search; /* Search stuff */ 13584260Sobrien el_signal_t el_signal; /* Signal handling stuff */ 136148834Sstefanf el_read_t el_read; /* Character reading stuff */ 1371573Srgrimes}; 1381573Srgrimes 139148834Sstefanfprotected int el_editmode(EditLine *, int, const char **); 14084260Sobrien 14184260Sobrien#ifdef DEBUG 142148834Sstefanf#define EL_ABORT(a) do { \ 143148834Sstefanf fprintf(el->el_errfile, "%s, %d: ", \ 144148834Sstefanf __FILE__, __LINE__); \ 145148834Sstefanf fprintf a; \ 146148834Sstefanf abort(); \ 147148834Sstefanf } while( /*CONSTCOND*/0); 14884260Sobrien#else 14984260Sobrien#define EL_ABORT(a) abort() 15084260Sobrien#endif 1511573Srgrimes#endif /* _h_el */ 152