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. 16148834Sstefanf * 3. Neither the name of the University nor the names of its contributors 171573Srgrimes * may be used to endorse or promote products derived from this software 181573Srgrimes * without specific prior written permission. 191573Srgrimes * 201573Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 211573Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 221573Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 231573Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 241573Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 251573Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 261573Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 271573Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 281573Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 291573Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 301573Srgrimes * SUCH DAMAGE. 311573Srgrimes * 321573Srgrimes * @(#)term.h 8.1 (Berkeley) 6/4/93 33170511Sstefanf * $NetBSD: term.h,v 1.18 2006/11/24 00:01:17 christos Exp $ 3463948Sache * $FreeBSD$ 351573Srgrimes */ 361573Srgrimes 371573Srgrimes/* 381573Srgrimes * el.term.h: Termcap header 391573Srgrimes */ 401573Srgrimes#ifndef _h_el_term 4184260Sobrien#define _h_el_term 421573Srgrimes 431573Srgrimes#include "histedit.h" 441573Srgrimes 4584260Sobrientypedef struct { /* Symbolic function key bindings */ 46148834Sstefanf const char *name; /* name of the key */ 4784260Sobrien int key; /* Index in termcap table */ 4884260Sobrien key_value_t fun; /* Function bound to it */ 4984260Sobrien int type; /* Type of function */ 501573Srgrimes} fkey_t; 511573Srgrimes 521573Srgrimestypedef struct { 53148834Sstefanf const char *t_name; /* the terminal name */ 5484260Sobrien coord_t t_size; /* # lines and cols */ 5584260Sobrien int t_flags; 5684260Sobrien#define TERM_CAN_INSERT 0x001 /* Has insert cap */ 5784260Sobrien#define TERM_CAN_DELETE 0x002 /* Has delete cap */ 5884260Sobrien#define TERM_CAN_CEOL 0x004 /* Has CEOL cap */ 5984260Sobrien#define TERM_CAN_TAB 0x008 /* Can use tabs */ 6084260Sobrien#define TERM_CAN_ME 0x010 /* Can turn all attrs. */ 6184260Sobrien#define TERM_CAN_UP 0x020 /* Can move up */ 6284260Sobrien#define TERM_HAS_META 0x040 /* Has a meta key */ 6384260Sobrien#define TERM_HAS_AUTO_MARGINS 0x080 /* Has auto margins */ 6484260Sobrien#define TERM_HAS_MAGIC_MARGINS 0x100 /* Has magic margins */ 6584260Sobrien char *t_buf; /* Termcap buffer */ 6684260Sobrien int t_loc; /* location used */ 6784260Sobrien char **t_str; /* termcap strings */ 6884260Sobrien int *t_val; /* termcap values */ 6984260Sobrien char *t_cap; /* Termcap buffer */ 7084260Sobrien fkey_t *t_fkey; /* Array of keys */ 711573Srgrimes} el_term_t; 721573Srgrimes 731573Srgrimes/* 741573Srgrimes * fKey indexes 751573Srgrimes */ 7684260Sobrien#define A_K_DN 0 7784260Sobrien#define A_K_UP 1 7884260Sobrien#define A_K_LT 2 7984260Sobrien#define A_K_RT 3 8084260Sobrien#define A_K_HO 4 8184260Sobrien#define A_K_EN 5 82212235Sjilles#define A_K_DE 6 83212235Sjilles#define A_K_NKEYS 7 841573Srgrimes 8584260Sobrienprotected void term_move_to_line(EditLine *, int); 8684260Sobrienprotected void term_move_to_char(EditLine *, int); 8784260Sobrienprotected void term_clear_EOL(EditLine *, int); 88237738Spfgprotected void term_overwrite(EditLine *, const char *, size_t); 8984260Sobrienprotected void term_insertwrite(EditLine *, char *, int); 9084260Sobrienprotected void term_deletechars(EditLine *, int); 9184260Sobrienprotected void term_clear_screen(EditLine *); 9284260Sobrienprotected void term_beep(EditLine *); 9384260Sobrienprotected int term_change_size(EditLine *, int, int); 9484260Sobrienprotected int term_get_size(EditLine *, int *, int *); 9584260Sobrienprotected int term_init(EditLine *); 9684260Sobrienprotected void term_bind_arrow(EditLine *); 97148834Sstefanfprotected void term_print_arrow(EditLine *, const char *); 98148834Sstefanfprotected int term_clear_arrow(EditLine *, const char *); 99148834Sstefanfprotected int term_set_arrow(EditLine *, const char *, key_value_t *, int); 10084260Sobrienprotected void term_end(EditLine *); 101148834Sstefanfprotected void term_get(EditLine *, const char **); 102148834Sstefanfprotected int term_set(EditLine *, const char *); 103148834Sstefanfprotected int term_settc(EditLine *, int, const char **); 104170511Sstefanfprotected int term_gettc(EditLine *, int, char **); 105148834Sstefanfprotected int term_telltc(EditLine *, int, const char **); 106148834Sstefanfprotected int term_echotc(EditLine *, int, const char **); 107167457Sstefanfprotected void term_writec(EditLine *, int); 108237738Spfgprotected int term__putc(EditLine *, int); 109237738Spfgprotected void term__flush(EditLine *); 1101573Srgrimes 1111573Srgrimes/* 1121573Srgrimes * Easy access macros 1131573Srgrimes */ 11484260Sobrien#define EL_FLAGS (el)->el_term.t_flags 1151573Srgrimes 11684260Sobrien#define EL_CAN_INSERT (EL_FLAGS & TERM_CAN_INSERT) 11784260Sobrien#define EL_CAN_DELETE (EL_FLAGS & TERM_CAN_DELETE) 11884260Sobrien#define EL_CAN_CEOL (EL_FLAGS & TERM_CAN_CEOL) 11984260Sobrien#define EL_CAN_TAB (EL_FLAGS & TERM_CAN_TAB) 12084260Sobrien#define EL_CAN_ME (EL_FLAGS & TERM_CAN_ME) 121148834Sstefanf#define EL_CAN_UP (EL_FLAGS & TERM_CAN_UP) 12284260Sobrien#define EL_HAS_META (EL_FLAGS & TERM_HAS_META) 12384260Sobrien#define EL_HAS_AUTO_MARGINS (EL_FLAGS & TERM_HAS_AUTO_MARGINS) 12484260Sobrien#define EL_HAS_MAGIC_MARGINS (EL_FLAGS & TERM_HAS_MAGIC_MARGINS) 1251573Srgrimes 1261573Srgrimes#endif /* _h_el_term */ 127