term.h revision 9898
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.
161573Srgrimes * 3. All advertising materials mentioning features or use of this software
171573Srgrimes *    must display the following acknowledgement:
181573Srgrimes *	This product includes software developed by the University of
191573Srgrimes *	California, Berkeley and its contributors.
201573Srgrimes * 4. Neither the name of the University nor the names of its contributors
211573Srgrimes *    may be used to endorse or promote products derived from this software
221573Srgrimes *    without specific prior written permission.
231573Srgrimes *
241573Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
251573Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
261573Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
271573Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
281573Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
291573Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
301573Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
311573Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
321573Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
331573Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
341573Srgrimes * SUCH DAMAGE.
351573Srgrimes *
361573Srgrimes *	@(#)term.h	8.1 (Berkeley) 6/4/93
371573Srgrimes */
381573Srgrimes
391573Srgrimes/*
401573Srgrimes * el.term.h: Termcap header
411573Srgrimes */
421573Srgrimes#ifndef _h_el_term
431573Srgrimes#define _h_el_term
441573Srgrimes
451573Srgrimes#include "histedit.h"
461573Srgrimes
471573Srgrimestypedef struct {	/* Symbolic function key bindings	*/
481573Srgrimes    char       *name;	/* name of the key			*/
491573Srgrimes    int     	key;	/* Index in termcap table		*/
501573Srgrimes    key_value_t fun;	/* Function bound to it			*/
511573Srgrimes    int	        type;	/* Type of function			*/
521573Srgrimes} fkey_t;
531573Srgrimes
541573Srgrimestypedef struct {
551573Srgrimes    coord_t t_size;			/* # lines and cols	*/
561573Srgrimes    bool_t  t_flags;
571573Srgrimes#define TERM_CAN_INSERT		0x01	/* Has insert cap	*/
581573Srgrimes#define TERM_CAN_DELETE		0x02	/* Has delete cap	*/
591573Srgrimes#define TERM_CAN_CEOL		0x04	/* Has CEOL cap		*/
601573Srgrimes#define TERM_CAN_TAB		0x08	/* Can use tabs		*/
611573Srgrimes#define TERM_CAN_ME		0x10	/* Can turn all attrs.	*/
621573Srgrimes#define TERM_CAN_UP		0x20	/* Can move up		*/
631573Srgrimes#define TERM_HAS_META		0x40	/* Has a meta key	*/
641573Srgrimes    char   *t_buf;			/* Termcap buffer	*/
651573Srgrimes    int	    t_loc;			/* location used	*/
661573Srgrimes    char  **t_str;			/* termcap strings	*/
671573Srgrimes    int	   *t_val;			/* termcap values	*/
681573Srgrimes    char   *t_cap;			/* Termcap buffer	*/
691573Srgrimes    fkey_t *t_fkey;			/* Array of keys	*/
701573Srgrimes} el_term_t;
711573Srgrimes
721573Srgrimes/*
731573Srgrimes * fKey indexes
741573Srgrimes */
751573Srgrimes#define A_K_DN		0
761573Srgrimes#define A_K_UP		1
771573Srgrimes#define A_K_LT		2
781573Srgrimes#define A_K_RT		3
791573Srgrimes#define A_K_NKEYS	4
801573Srgrimes
811573Srgrimesprotected void term_move_to_line	__P((EditLine *, int));
821573Srgrimesprotected void term_move_to_char	__P((EditLine *, int));
831573Srgrimesprotected void term_clear_EOL		__P((EditLine *, int));
841573Srgrimesprotected void term_overwrite		__P((EditLine *, char *, int));
851573Srgrimesprotected void term_insertwrite		__P((EditLine *, char *, int));
861573Srgrimesprotected void term_deletechars		__P((EditLine *, int));
871573Srgrimesprotected void term_clear_screen	__P((EditLine *));
881573Srgrimesprotected void term_beep		__P((EditLine *));
891573Srgrimesprotected void term_change_size		__P((EditLine *, int, int));
901573Srgrimesprotected int  term_get_size		__P((EditLine *, int *, int *));
911573Srgrimesprotected int  term_init		__P((EditLine *));
921573Srgrimesprotected void term_bind_arrow		__P((EditLine *));
931573Srgrimesprotected void term_print_arrow		__P((EditLine *, char *));
941573Srgrimesprotected int  term_clear_arrow		__P((EditLine *, char *));
958870Srgrimesprotected int  term_set_arrow		__P((EditLine *, char *,
961573Srgrimes					     key_value_t *, int));
971573Srgrimesprotected void term_end			__P((EditLine *));
981573Srgrimesprotected int  term_set			__P((EditLine *, char *));
991573Srgrimesprotected int  term_settc		__P((EditLine *, int, char **));
1001573Srgrimesprotected int  term_telltc		__P((EditLine *, int, char **));
1011573Srgrimesprotected int  term_echotc		__P((EditLine *, int, char **));
1021573Srgrimes
1039898Sacheprotected int  term__putc		__P((int));
1041573Srgrimesprotected void term__flush		__P((void));
1051573Srgrimes
1061573Srgrimes/*
1071573Srgrimes * Easy access macros
1081573Srgrimes */
1091573Srgrimes#define EL_FLAGS	(el)->el_term.t_flags
1101573Srgrimes
1111573Srgrimes#define EL_CAN_INSERT	(EL_FLAGS & TERM_CAN_INSERT)
1121573Srgrimes#define EL_CAN_DELETE	(EL_FLAGS & TERM_CAN_DELETE)
1131573Srgrimes#define EL_CAN_CEOL	(EL_FLAGS & TERM_CAN_CEOL)
1141573Srgrimes#define EL_CAN_TAB	(EL_FLAGS & TERM_CAN_TAB)
1151573Srgrimes#define EL_CAN_ME	(EL_FLAGS & TERM_CAN_ME)
1161573Srgrimes#define EL_HAS_META	(EL_FLAGS & TERM_HAS_META)
1171573Srgrimes
1181573Srgrimes#endif /* _h_el_term */
119