root/src/noitedit/el.h

Revision 6480ae14408dabfad215b4f1369579f864f4b558, 5.9 kB (checked in by Theo Schlossnagle <jesus@omniti.com>, 6 years ago)

fixes #105... it's a hack, but it appears to work... loses invalid sequences, but I think that's the desired outcome... luckily

  • Property mode set to 100644
Line 
1 /*      $NetBSD: el.h,v 1.8 2001/01/06 14:44:50 jdolecek Exp $  */
2
3 /*-
4  * Copyright (c) 1992, 1993
5  *      The Regents of the University of California.  All rights reserved.
6  *
7  * This code is derived from software contributed to Berkeley by
8  * Christos Zoulas of Cornell University.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. All advertising materials mentioning features or use of this software
19  *    must display the following acknowledgement:
20  *      This product includes software developed by the University of
21  *      California, Berkeley and its contributors.
22  * 4. Neither the name of the University nor the names of its contributors
23  *    may be used to endorse or promote products derived from this software
24  *    without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36  * SUCH DAMAGE.
37  *
38  *      @(#)el.h        8.1 (Berkeley) 6/4/93
39  */
40
41 /*
42  * el.h: Internal structures.
43  */
44 #ifndef _h_el
45 #define _h_el
46 /*
47  * Local defaults
48    #define      VIDEFAULT
49    #define      KSHVI
50  */
51 #define ANCHOR
52
53 #include "noit_defines.h"
54 #include "eventer/eventer.h"
55 #include <stdio.h>
56 #ifdef HAVE_SYS_TYPES_H
57 #include <sys/types.h>
58 #endif
59 #ifdef HAVE_TERMIO_H
60 #include <termio.h>
61 #endif
62 #ifdef HAVE_TERMIOS_H
63 #include <termios.h>
64 #endif
65 #ifdef HAVE_CURSES_H
66 #include <curses.h>
67 #endif
68 #ifdef HAVE_TERM_H
69 #include <term.h>
70 #endif
71
72 #define EL_BUFSIZ       1024            /* Maximum line size            */
73
74 #define HANDLE_SIGNALS  1<<0
75 #define NO_TTY          1<<1
76 #define EDIT_DISABLED   1<<2
77
78 typedef int bool_t;                     /* True or not                  */
79
80 typedef unsigned char el_action_t;      /* Index to command array       */
81
82 typedef struct coord_t {                /* Position on the screen       */
83         int     h;
84         int     v;
85 } coord_t;
86
87 typedef struct el_line_t {
88         char    *buffer;                /* Input line                   */
89         char    *cursor;                /* Cursor position              */
90         char    *lastchar;              /* Last character               */
91         const char      *limit;                 /* Max position                 */
92 } el_line_t;
93
94 /*
95  * Editor state
96  */
97 typedef struct el_state_t {
98         int             inputmode;      /* What mode are we in?         */
99         int             doingarg;       /* Are we getting an argument?  */
100         int             argument;       /* Numeric argument             */
101         int             metanext;       /* Is the next char a meta char */
102         el_action_t     lastcmd;        /* Previous command             */
103 } el_state_t;
104
105 /*
106  * Until we come up with something better...
107  */
108 #define el_malloc(a)    malloc(a)
109 #define el_realloc(a,b) realloc(a, b)
110 #define el_free(a)      free(a)
111
112 #include "noitedit/tty.h"
113 #include "noitedit/prompt.h"
114 #include "noitedit/key.h"
115 #include "noitedit/el_term.h"
116 #include "noitedit/refresh.h"
117 #include "noitedit/chared.h"
118 #include "noitedit/common.h"
119 #include "noitedit/search.h"
120 #include "noitedit/hist.h"
121 #include "noitedit/map.h"
122 #include "noitedit/parse.h"
123 #include "noitedit/sig.h"
124 #include "noitedit/help.h"
125
126 struct editline {
127         char             *el_prog;      /* the program name             */
128         int               el_outfd;     /* Output file descriptor       */
129         eventer_t         el_out_e;
130         int               el_errfd;     /* Error file descriptor        */
131         eventer_t         el_err_e;
132         int               el_infd;      /* Input file descriptor        */
133         eventer_t         el_in_e;
134         int               el_flags;     /* Various flags.               */
135         coord_t           el_cursor;    /* Cursor location              */
136         char            **el_display;   /* Real screen image = what is there */
137         char            **el_vdisplay;  /* Virtual screen image = what we see */
138         key_node_t       *el_keystate;  /* last char keystate progression */
139         el_line_t         el_line;      /* The current line information */
140         el_state_t        el_state;     /* Current editor state         */
141         el_term_t         el_term;      /* Terminal dependent stuff     */
142         el_tty_t          el_tty;       /* Tty dependent stuff          */
143         el_refresh_t      el_refresh;   /* Refresh stuff                */
144         el_prompt_t       el_prompt;    /* Prompt stuff                 */
145         el_prompt_t       el_rprompt;   /* Prompt stuff                 */
146         el_chared_t       el_chared;    /* Characted editor stuff       */
147         el_map_t          el_map;       /* Key mapping stuff            */
148         el_key_t          el_key;       /* Key binding stuff            */
149         el_history_t      el_history;   /* History stuff                */
150         el_search_t       el_search;    /* Search stuff                 */
151         el_signal_t       el_signal;    /* Signal handling stuff        */
152         int               el_nb_state;  /* Did we eagain?               */
153         int             (*el_err_printf)(struct editline *, const char *, ...);
154         int             (*el_std_printf)(struct editline *, const char *, ...);
155         int             (*el_std_putc)(int, struct editline *);
156         int             (*el_std_flush)(struct editline *);
157         void             *el_userdata;
158 };
159
160 protected int   el_editmode(EditLine *, int, char **);
161 protected int   el_err_printf(EditLine *, const char *, ...);
162 protected int   el_err_vprintf(EditLine *, const char *, va_list);
163 protected int   el_std_printf(EditLine *, const char *, ...);
164 protected int   el_std_vprintf(EditLine *, const char *, va_list);
165 protected int   el_std_putc(int, EditLine *);
166 protected int   el_std_flush(EditLine *);
167
168 #ifdef DEBUG
169 #define EL_ABORT(a)     (void) (el->el_err_printf(el, "%s, %d: ", \
170                                 __FILE__, __LINE__), fprintf a, abort())
171 #else
172 #define EL_ABORT(a)     abort()
173 #endif
174 #endif /* _h_el */
Note: See TracBrowser for help on using the browser.