edit.h revision 3e14f97f673e8a630f076077de35afdd43dc1587
/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1982-2010 AT&T Intellectual Property *
* and is licensed under the *
* Common Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* David Korn <dgk@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
#ifndef SEARCHSIZE
/*
* edit.h - common data structure for vi and emacs edit options
*
* David Korn
* AT&T Labs
*
*/
#define SEARCHSIZE 80
# define ed_winsize() (SEARCHSIZE)
#else
#if !KSHELL
# include <setjmp.h>
# include <sig.h>
# include <ctype.h>
#endif /* KSHELL */
#include "terminal.h"
#define STRIP 0377
#define LOOKAHEAD 80
#if SHOPT_MULTIBYTE
# ifndef ESS_MAXCHAR
# include "national.h"
# endif /* ESS_MAXCHAR */
#else
typedef char genchar;
# define CHARSIZE 1
#endif /* SHOPT_MULTIBYTE */
#define TABSIZE 8
#define PRSIZE 160
typedef struct _edit_pos
{
unsigned short line;
unsigned short col;
} Edpos_t;
typedef struct edit
{
int e_kill;
int e_erase;
int e_werase;
int e_eof;
int e_lnext;
int e_fchar;
int e_plen; /* length of prompt string */
char e_crlf; /* zero if cannot return to beginning of line */
char e_nocrnl; /* don't put a new-line with ^L */
int e_llimit; /* line length limit */
int e_hline; /* current history line number */
int e_hloff; /* line number offset for command */
int e_hismin; /* minimum history line number */
int e_hismax; /* maximum history line number */
int e_raw; /* set when in raw mode or alt mode */
int e_cur; /* current line position */
int e_eol; /* end-of-line position */
int e_pcur; /* current physical line position */
int e_peol; /* end of physical line position */
int e_mode; /* edit mode */
int e_lookahead; /* index in look-ahead buffer */
int e_repeat;
int e_saved;
int e_fcol; /* first column */
int e_ucol; /* column for undo */
int e_wsize; /* width of display window */
char *e_outbase; /* pointer to start of output buffer */
char *e_outptr; /* pointer to position in output buffer */
char *e_outlast; /* pointer to end of output buffer */
char *e_prompt; /* pointer to buffer containing the prompt */
int e_fd; /* file descriptor */
int e_ttyspeed; /* line speed, also indicates tty parms are valid */
int e_tabcount;
#ifdef _hdr_utime
char *e_tty;
#endif
#if SHOPT_OLDTERMIO
char e_echoctl;
char e_tcgeta;
#endif
#if SHOPT_MULTIBYTE
int e_curchar;
int e_cursize;
#endif
int *e_globals; /* global variables */
char e_inmacro; /* processing macro expansion */
#if KSHELL
#else
#endif /* KSHELL */
int e_savefd; /* file descriptor for saved terminal state */
void *e_vi; /* vi specific data */
void *e_emacs; /* emacs specific data */
char *e_stkptr; /* saved stack pointer */
int e_stkoff; /* saved stack offset */
char **e_clist; /* completion list after <ESC>= */
int e_nlist; /* number of elements on completion list */
int e_multiline; /* allow multiple lines for editing */
int e_winsz; /* columns in window */
} Edit_t;
#define FAST 2
#define SLOW 1
#if ( 'a' == 97) /* ASCII? */
# define cntl(x) (x&037)
#else
(c=='I'?'\t':(c=='J'?'\n':(c=='T'?60:(c=='U'?61:(c=='V'?50: \
(c=='W'?38:(c=='Z'?63:(c=='['?39:(c==']'?29: \
(c<'J'?c+1-'A':(c+10-'J'))))))))))))))))
#endif
#if !KSHELL
# define STRIP 0377
# define GMACS 1
# define EMACS 2
# define VIRAW 4
# define EDITVI 8
# define NOHIST 16
# define EDITMASK 15
extern char opt_flag;
# ifdef SYSCALL
# else
# endif /* SYSCALL */
#endif /* KSHELL */
extern void ed_putchar(Edit_t*, int);
extern void ed_ringbell(void);
extern int ed_getchar(Edit_t*,int);
extern int ed_window(void);
extern void ed_ungetchar(Edit_t*,int);
extern int ed_viread(void*, int, char*, int, int);
extern int ed_read(void*, int, char*, int, int);
extern int ed_emacsread(void*, int, char*, int, int);
#if KSHELL
extern int ed_fulledit(Edit_t*);
#endif /* KSHELL */
# if SHOPT_MULTIBYTE
extern int ed_internal(const char*, genchar*);
extern int ed_external(const genchar*, char*);
extern int ed_setwidth(const char*);
# endif /* SHOPT_MULTIBYTE */
extern const char e_runvi[];
#if !KSHELL
extern const char e_version[];
#endif /* KSHELL */
#if SHOPT_HISTEXPAND
/* flags */
/* modifier flags */
/* flags to be returned */
extern int hist_expand(const char *, char **);
#endif
#endif
#endif