term.h revision 167457
1131826Sharti/*- 2131826Sharti * Copyright (c) 1992, 1993 3131826Sharti * The Regents of the University of California. All rights reserved. 4131826Sharti * 5131826Sharti * This code is derived from software contributed to Berkeley by 6131826Sharti * Christos Zoulas of Cornell University. 7131826Sharti * 8131826Sharti * Redistribution and use in source and binary forms, with or without 9131826Sharti * modification, are permitted provided that the following conditions 10131826Sharti * are met: 11131826Sharti * 1. Redistributions of source code must retain the above copyright 12131826Sharti * notice, this list of conditions and the following disclaimer. 13131826Sharti * 2. Redistributions in binary form must reproduce the above copyright 14131826Sharti * notice, this list of conditions and the following disclaimer in the 15131826Sharti * documentation and/or other materials provided with the distribution. 16131826Sharti * 3. Neither the name of the University nor the names of its contributors 17131826Sharti * may be used to endorse or promote products derived from this software 18131826Sharti * without specific prior written permission. 19131826Sharti * 20131826Sharti * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21131826Sharti * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22131826Sharti * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23131826Sharti * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24131826Sharti * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25131826Sharti * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26131826Sharti * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27131826Sharti * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28131826Sharti * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29131826Sharti * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30131826Sharti * SUCH DAMAGE. 31131826Sharti * 32131826Sharti * @(#)term.h 8.1 (Berkeley) 6/4/93 33131826Sharti * $NetBSD: term.h,v 1.17 2006/03/06 21:11:56 christos Exp $ 34131826Sharti * $FreeBSD: head/lib/libedit/term.h 167457 2007-03-11 18:30:22Z stefanf $ 35131826Sharti */ 36131826Sharti 37131826Sharti/* 38131826Sharti * el.term.h: Termcap header 39131826Sharti */ 40131826Sharti#ifndef _h_el_term 41131826Sharti#define _h_el_term 42131826Sharti 43131826Sharti#include "histedit.h" 44131826Sharti 45131826Shartitypedef struct { /* Symbolic function key bindings */ 46131826Sharti const char *name; /* name of the key */ 47131826Sharti int key; /* Index in termcap table */ 48131826Sharti key_value_t fun; /* Function bound to it */ 49131826Sharti int type; /* Type of function */ 50131826Sharti} fkey_t; 51131826Sharti 52131826Shartitypedef struct { 53131826Sharti const char *t_name; /* the terminal name */ 54131826Sharti coord_t t_size; /* # lines and cols */ 55131826Sharti int t_flags; 56131826Sharti#define TERM_CAN_INSERT 0x001 /* Has insert cap */ 57131826Sharti#define TERM_CAN_DELETE 0x002 /* Has delete cap */ 58131826Sharti#define TERM_CAN_CEOL 0x004 /* Has CEOL cap */ 59131826Sharti#define TERM_CAN_TAB 0x008 /* Can use tabs */ 60131826Sharti#define TERM_CAN_ME 0x010 /* Can turn all attrs. */ 61131826Sharti#define TERM_CAN_UP 0x020 /* Can move up */ 62131826Sharti#define TERM_HAS_META 0x040 /* Has a meta key */ 63131826Sharti#define TERM_HAS_AUTO_MARGINS 0x080 /* Has auto margins */ 64131826Sharti#define TERM_HAS_MAGIC_MARGINS 0x100 /* Has magic margins */ 65131826Sharti char *t_buf; /* Termcap buffer */ 66131826Sharti int t_loc; /* location used */ 67131826Sharti char **t_str; /* termcap strings */ 68131826Sharti int *t_val; /* termcap values */ 69131826Sharti char *t_cap; /* Termcap buffer */ 70131826Sharti fkey_t *t_fkey; /* Array of keys */ 71131826Sharti} el_term_t; 72131826Sharti 73131826Sharti/* 74131826Sharti * fKey indexes 75131826Sharti */ 76131826Sharti#define A_K_DN 0 77131826Sharti#define A_K_UP 1 78131826Sharti#define A_K_LT 2 79131826Sharti#define A_K_RT 3 80131826Sharti#define A_K_HO 4 81131826Sharti#define A_K_EN 5 82131826Sharti#define A_K_NKEYS 6 83131826Sharti 84131826Shartiprotected void term_move_to_line(EditLine *, int); 85131826Shartiprotected void term_move_to_char(EditLine *, int); 86131826Shartiprotected void term_clear_EOL(EditLine *, int); 87131826Shartiprotected void term_overwrite(EditLine *, const char *, int); 88131826Shartiprotected void term_insertwrite(EditLine *, char *, int); 89131826Shartiprotected void term_deletechars(EditLine *, int); 90131826Shartiprotected void term_clear_screen(EditLine *); 91131826Shartiprotected void term_beep(EditLine *); 92131826Shartiprotected int term_change_size(EditLine *, int, int); 93131826Shartiprotected int term_get_size(EditLine *, int *, int *); 94131826Shartiprotected int term_init(EditLine *); 95131826Shartiprotected void term_bind_arrow(EditLine *); 96131826Shartiprotected void term_print_arrow(EditLine *, const char *); 97131826Shartiprotected int term_clear_arrow(EditLine *, const char *); 98131826Shartiprotected int term_set_arrow(EditLine *, const char *, key_value_t *, int); 99131826Shartiprotected void term_end(EditLine *); 100131826Shartiprotected void term_get(EditLine *, const char **); 101131826Shartiprotected int term_set(EditLine *, const char *); 102131826Shartiprotected int term_settc(EditLine *, int, const char **); 103131826Shartiprotected int term_telltc(EditLine *, int, const char **); 104131826Shartiprotected int term_echotc(EditLine *, int, const char **); 105131826Shartiprotected void term_writec(EditLine *, int); 106131826Shartiprotected int term__putc(int); 107131826Shartiprotected void term__flush(void); 108131826Sharti 109131826Sharti/* 110131826Sharti * Easy access macros 111131826Sharti */ 112131826Sharti#define EL_FLAGS (el)->el_term.t_flags 113131826Sharti 114131826Sharti#define EL_CAN_INSERT (EL_FLAGS & TERM_CAN_INSERT) 115131826Sharti#define EL_CAN_DELETE (EL_FLAGS & TERM_CAN_DELETE) 116131826Sharti#define EL_CAN_CEOL (EL_FLAGS & TERM_CAN_CEOL) 117131826Sharti#define EL_CAN_TAB (EL_FLAGS & TERM_CAN_TAB) 118131826Sharti#define EL_CAN_ME (EL_FLAGS & TERM_CAN_ME) 119131826Sharti#define EL_CAN_UP (EL_FLAGS & TERM_CAN_UP) 120131826Sharti#define EL_HAS_META (EL_FLAGS & TERM_HAS_META) 121131826Sharti#define EL_HAS_AUTO_MARGINS (EL_FLAGS & TERM_HAS_AUTO_MARGINS) 122131826Sharti#define EL_HAS_MAGIC_MARGINS (EL_FLAGS & TERM_HAS_MAGIC_MARGINS) 123131826Sharti 124131826Sharti#endif /* _h_el_term */ 125131826Sharti