Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / programs / dtksh / ksh93 / src / cmd / ksh93 / include / edit.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $XConsortium: edit.h /main/3 1995/11/01 16:39:33 rswiston $ */
24 /***************************************************************
25 *                                                              *
26 *                      AT&T - PROPRIETARY                      *
27 *                                                              *
28 *        THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF        *
29 *                    AT&T BELL LABORATORIES                    *
30 *         AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN         *
31 *            ACCORDANCE WITH APPLICABLE AGREEMENTS             *
32 *                                                              *
33 *                Copyright (c) 1995 AT&T Corp.                 *
34 *              Unpublished & Not for Publication               *
35 *                     All Rights Reserved                      *
36 *                                                              *
37 *       The copyright notice above does not evidence any       *
38 *      actual or intended publication of such source code      *
39 *                                                              *
40 *               This software was created by the               *
41 *           Advanced Software Technology Department            *
42 *                    AT&T Bell Laboratories                    *
43 *                                                              *
44 *               For further information contact                *
45 *                    {research,attmail}!dgk                    *
46 *                                                              *
47 ***************************************************************/
48
49 /* : : generated by proto : : */
50                   
51 #ifndef SEARCHSIZE
52 #if !defined(__PROTO__)
53 #if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
54 #if defined(__cplusplus)
55 #define __MANGLE__      "C"
56 #else
57 #define __MANGLE__
58 #endif
59 #define __STDARG__
60 #define __PROTO__(x)    x
61 #define __OTORP__(x)
62 #define __PARAM__(n,o)  n
63 #if !defined(__STDC__) && !defined(__cplusplus)
64 #if !defined(c_plusplus)
65 #define const
66 #endif
67 #define signed
68 #define void            int
69 #define volatile
70 #define __V_            char
71 #else
72 #define __V_            void
73 #endif
74 #else
75 #define __PROTO__(x)    ()
76 #define __OTORP__(x)    x
77 #define __PARAM__(n,o)  o
78 #define __MANGLE__
79 #define __V_            char
80 #define const
81 #define signed
82 #define void            int
83 #define volatile
84 #endif
85 #if defined(__cplusplus) || defined(c_plusplus)
86 #define __VARARG__      ...
87 #else
88 #define __VARARG__
89 #endif
90 #if defined(__STDARG__)
91 #define __VA_START__(p,a)       va_start(p,a)
92 #else
93 #define __VA_START__(p,a)       va_start(p)
94 #endif
95 #endif
96
97 /*
98  *  edit.h -  common data structure for vi and emacs edit options
99  *
100  *   David Korn
101  *   AT&T Bell Laboratories
102  *   Room 2B-102
103  *   Murray Hill, N. J. 07974
104  *   Tel. x7975
105  *
106  */
107
108 #define SEARCHSIZE      80
109
110 #include        "FEATURE/options"
111 #if !defined(SHOPT_VSH) && !defined (SHOPT_ESH)
112 #   define ed_winsize() (SEARCHSIZE)
113 #else
114
115 #ifndef KSHELL
116 #   include     <setjmp.h>
117 #   include     <sig.h>
118 #   include     <ctype.h>
119 #endif /* KSHELL */
120
121 #include        "FEATURE/setjmp"
122
123 #ifdef SHOPT_SEVENBIT
124 #   define STRIP        0177
125 #else
126 #   define STRIP        0377
127 #endif /* SHOPT_SEVENBIT */
128 #define LOOKAHEAD       80
129
130 #ifdef SHOPT_MULTIBYTE
131 #   ifndef ESS_MAXCHAR
132 #   include     "national.h"
133 #   endif /* ESS_MAXCHAR */
134 #   if ESS_MAXCHAR<=2
135         typedef unsigned short genchar;
136 #   else
137         typedef long genchar;
138 #   endif
139 #   define CHARSIZE     2
140 #else
141     typedef char genchar;
142 #   define CHARSIZE     1
143 #endif /* SHOPT_MULTIBYTE */
144
145 #define TABSIZE 8
146 #define PRSIZE  80
147 #define MAXLINE 502             /* longest edit line permitted */
148
149 struct edit
150 {
151         int     e_kill;
152         int     e_erase;
153         int     e_werase;
154         int     e_eof;
155         int     e_lnext;
156         int     e_fchar;
157         char    e_plen;         /* length of prompt string */
158         char    e_crlf;         /* zero if cannot return to beginning of line */
159         sigjmp_buf e_env;
160         int     e_llimit;       /* line length limit */
161         int     e_hline;        /* current history line number */
162         int     e_hloff;        /* line number offset for command */
163         int     e_hismin;       /* minimum history line number */
164         int     e_hismax;       /* maximum history line number */
165         int     e_raw;          /* set when in raw mode or alt mode */
166         int     e_cur;          /* current line position */
167         int     e_eol;          /* end-of-line position */
168         int     e_pcur;         /* current physical line position */
169         int     e_peol;         /* end of physical line position */
170         int     e_mode;         /* edit mode */
171         int     e_index;        /* index in look-ahead buffer */
172         int     e_repeat;
173         int     e_saved;
174         int     e_fcol;         /* first column */
175         int     e_ucol;         /* column for undo */
176         int     e_wsize;        /* width of display window */
177         char    *e_outbase;     /* pointer to start of output buffer */
178         char    *e_outptr;      /* pointer to position in output buffer */
179         char    *e_outlast;     /* pointer to end of output buffer */
180         genchar *e_inbuf;       /* pointer to input buffer */
181         char    *e_prompt;      /* pointer to buffer containing the prompt */
182         genchar *e_ubuf;        /* pointer to the undo buffer */
183         genchar *e_killbuf;     /* pointer to delete buffer */
184         char    e_search[SEARCHSIZE];   /* search string */
185         genchar *e_Ubuf;        /* temporary workspace buffer */
186         genchar *e_physbuf;     /* temporary workspace buffer */
187         int     e_lbuf[LOOKAHEAD];/* pointer to look-ahead buffer */
188         int     e_fd;           /* file descriptor */
189         int     e_ttyspeed;     /* line speed, also indicates tty parms are valid */
190         int     *e_globals;     /* global variables */
191         genchar *e_window;      /* display window  image */
192         char    e_inmacro;      /* processing macro expansion */
193 #ifndef KSHELL
194         char    e_prbuff[PRSIZE]; /* prompt buffer */
195 #endif /* KSHELL */
196 };
197
198 #undef MAXWINDOW
199 #define MAXWINDOW       160     /* maximum width window */
200 #define FAST    2
201 #define SLOW    1
202 #define ESC     033
203 #define UEOF    -2                      /* user eof char synonym */
204 #define UINTR   -3                      /* user intr char synonym */
205 #define UERASE  -4                      /* user erase char synonym */
206 #define UKILL   -5                      /* user kill char synonym */
207 #define UWERASE -6                      /* user word erase char synonym */
208 #define ULNEXT  -7                      /* user next literal char synonym */
209
210 #define cntl(x)         (x&037)
211
212 #ifndef KSHELL
213 #   define STRIP        0377
214 #   define GMACS        1
215 #   define EMACS        2
216 #   define VIRAW        4
217 #   define EDITVI       8
218 #   define NOHIST       16
219 #   define EDITMASK     15
220 #   define is_option(m) (opt_flag&(m))
221     extern __MANGLE__ char opt_flag;
222 #   ifdef SYSCALL
223 #       define read(fd,buff,n)  syscall(3,fd,buff,n)
224 #   else
225 #       define read(fd,buff,n)  rEAd(fd,buff,n)
226 #   endif /* SYSCALL */
227 #endif  /* KSHELL */
228
229 extern __MANGLE__ struct edit editb;
230
231 extern __MANGLE__ void  ed_crlf __PROTO__((void));
232 extern __MANGLE__ void  ed_putchar __PROTO__((int));
233 extern __MANGLE__ void  ed_ringbell __PROTO__((void));
234 extern __MANGLE__ void  ed_setup __PROTO__((int));
235 extern __MANGLE__ void  ed_flush __PROTO__((void));
236 extern __MANGLE__ int   ed_getchar __PROTO__((int));
237 extern __MANGLE__ int   ed_virt_to_phys __PROTO__((genchar*,genchar*,int,int,int));
238 extern __MANGLE__ int   ed_window __PROTO__((void));
239 extern __MANGLE__ void  ed_ungetchar __PROTO__((int));
240 extern __MANGLE__ int   ed_viread __PROTO__((int, char*, int));
241 extern __MANGLE__ int   ed_read __PROTO__((int, char*, int));
242 extern __MANGLE__ int   ed_emacsread __PROTO__((int, char*, int));
243 #ifdef KSHELL
244         extern __MANGLE__ int   ed_macro __PROTO__((int));
245         extern __MANGLE__ int   ed_expand __PROTO__((char[],int*,int*,int));
246         extern __MANGLE__ int   ed_fulledit __PROTO__((void));
247 #endif /* KSHELL */
248 #   ifdef SHOPT_MULTIBYTE
249         extern __MANGLE__ int ed_internal __PROTO__((const char*, genchar*));
250         extern __MANGLE__ int ed_external __PROTO__((const genchar*, char*));
251         extern __MANGLE__ void ed_gencpy __PROTO__((genchar*,const genchar*));
252         extern __MANGLE__ void ed_genncpy __PROTO__((genchar*,const genchar*,int));
253         extern __MANGLE__ int ed_genlen __PROTO__((const genchar*));
254         extern __MANGLE__ int ed_setwidth __PROTO__((const char*));
255 #  endif /* SHOPT_MULTIBYTE */
256
257 extern __MANGLE__ const char    e_runvi[];
258 #ifndef KSHELL
259    extern __MANGLE__ const char e_version[];
260 #endif /* KSHELL */
261
262 #endif
263 #endif