1313981Spfg/* $NetBSD: terminal.h,v 1.7 2016/02/16 15:53:48 christos Exp $ */ 2276881Sbapt 31573Srgrimes/*- 41573Srgrimes * Copyright (c) 1992, 1993 51573Srgrimes * The Regents of the University of California. All rights reserved. 61573Srgrimes * 71573Srgrimes * This code is derived from software contributed to Berkeley by 81573Srgrimes * Christos Zoulas of Cornell University. 91573Srgrimes * 101573Srgrimes * Redistribution and use in source and binary forms, with or without 111573Srgrimes * modification, are permitted provided that the following conditions 121573Srgrimes * are met: 131573Srgrimes * 1. Redistributions of source code must retain the above copyright 141573Srgrimes * notice, this list of conditions and the following disclaimer. 151573Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 161573Srgrimes * notice, this list of conditions and the following disclaimer in the 171573Srgrimes * documentation and/or other materials provided with the distribution. 18148834Sstefanf * 3. Neither the name of the University nor the names of its contributors 191573Srgrimes * may be used to endorse or promote products derived from this software 201573Srgrimes * without specific prior written permission. 211573Srgrimes * 221573Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 231573Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 241573Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 251573Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 261573Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 271573Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 281573Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 291573Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 301573Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 311573Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 321573Srgrimes * SUCH DAMAGE. 331573Srgrimes * 341573Srgrimes * @(#)term.h 8.1 (Berkeley) 6/4/93 3563948Sache * $FreeBSD: stable/11/lib/libedit/terminal.h 313981 2017-02-20 03:33:59Z pfg $ 361573Srgrimes */ 371573Srgrimes 381573Srgrimes/* 391573Srgrimes * el.term.h: Termcap header 401573Srgrimes */ 41276881Sbapt#ifndef _h_el_terminal 42276881Sbapt#define _h_el_terminal 431573Srgrimes 4484260Sobrientypedef struct { /* Symbolic function key bindings */ 45276881Sbapt const Char *name; /* name of the key */ 4684260Sobrien int key; /* Index in termcap table */ 47276881Sbapt keymacro_value_t fun; /* Function bound to it */ 4884260Sobrien int type; /* Type of function */ 49276881Sbapt} funckey_t; 501573Srgrimes 511573Srgrimestypedef struct { 52148834Sstefanf const char *t_name; /* the terminal name */ 5384260Sobrien coord_t t_size; /* # lines and cols */ 5484260Sobrien int t_flags; 5584260Sobrien#define TERM_CAN_INSERT 0x001 /* Has insert cap */ 5684260Sobrien#define TERM_CAN_DELETE 0x002 /* Has delete cap */ 5784260Sobrien#define TERM_CAN_CEOL 0x004 /* Has CEOL cap */ 5884260Sobrien#define TERM_CAN_TAB 0x008 /* Can use tabs */ 5984260Sobrien#define TERM_CAN_ME 0x010 /* Can turn all attrs. */ 6084260Sobrien#define TERM_CAN_UP 0x020 /* Can move up */ 6184260Sobrien#define TERM_HAS_META 0x040 /* Has a meta key */ 6284260Sobrien#define TERM_HAS_AUTO_MARGINS 0x080 /* Has auto margins */ 6384260Sobrien#define TERM_HAS_MAGIC_MARGINS 0x100 /* Has magic margins */ 6484260Sobrien char *t_buf; /* Termcap buffer */ 65276881Sbapt size_t t_loc; /* location used */ 6684260Sobrien char **t_str; /* termcap strings */ 6784260Sobrien int *t_val; /* termcap values */ 6884260Sobrien char *t_cap; /* Termcap buffer */ 69276881Sbapt funckey_t *t_fkey; /* Array of keys */ 70276881Sbapt} el_terminal_t; 711573Srgrimes 721573Srgrimes/* 731573Srgrimes * fKey indexes 741573Srgrimes */ 7584260Sobrien#define A_K_DN 0 7684260Sobrien#define A_K_UP 1 7784260Sobrien#define A_K_LT 2 7884260Sobrien#define A_K_RT 3 7984260Sobrien#define A_K_HO 4 8084260Sobrien#define A_K_EN 5 81212235Sjilles#define A_K_DE 6 82212235Sjilles#define A_K_NKEYS 7 831573Srgrimes 84276881Sbaptprotected void terminal_move_to_line(EditLine *, int); 85276881Sbaptprotected void terminal_move_to_char(EditLine *, int); 86276881Sbaptprotected void terminal_clear_EOL(EditLine *, int); 87276881Sbaptprotected void terminal_overwrite(EditLine *, const Char *, size_t); 88276881Sbaptprotected void terminal_insertwrite(EditLine *, Char *, int); 89276881Sbaptprotected void terminal_deletechars(EditLine *, int); 90276881Sbaptprotected void terminal_clear_screen(EditLine *); 91276881Sbaptprotected void terminal_beep(EditLine *); 92276881Sbaptprotected int terminal_change_size(EditLine *, int, int); 93276881Sbaptprotected int terminal_get_size(EditLine *, int *, int *); 94276881Sbaptprotected int terminal_init(EditLine *); 95276881Sbaptprotected void terminal_bind_arrow(EditLine *); 96276881Sbaptprotected void terminal_print_arrow(EditLine *, const Char *); 97276881Sbaptprotected int terminal_clear_arrow(EditLine *, const Char *); 98276881Sbaptprotected int terminal_set_arrow(EditLine *, const Char *, keymacro_value_t *, int); 99276881Sbaptprotected void terminal_end(EditLine *); 100276881Sbaptprotected void terminal_get(EditLine *, const char **); 101276881Sbaptprotected int terminal_set(EditLine *, const char *); 102276881Sbaptprotected int terminal_settc(EditLine *, int, const Char **); 103276881Sbaptprotected int terminal_gettc(EditLine *, int, char **); 104276881Sbaptprotected int terminal_telltc(EditLine *, int, const Char **); 105276881Sbaptprotected int terminal_echotc(EditLine *, int, const Char **); 106313981Spfgprotected void terminal_writec(EditLine *, wint_t); 107313981Spfgprotected int terminal__putc(EditLine *, wint_t); 108276881Sbaptprotected void terminal__flush(EditLine *); 1091573Srgrimes 1101573Srgrimes/* 1111573Srgrimes * Easy access macros 1121573Srgrimes */ 113276881Sbapt#define EL_FLAGS (el)->el_terminal.t_flags 1141573Srgrimes 11584260Sobrien#define EL_CAN_INSERT (EL_FLAGS & TERM_CAN_INSERT) 11684260Sobrien#define EL_CAN_DELETE (EL_FLAGS & TERM_CAN_DELETE) 11784260Sobrien#define EL_CAN_CEOL (EL_FLAGS & TERM_CAN_CEOL) 11884260Sobrien#define EL_CAN_TAB (EL_FLAGS & TERM_CAN_TAB) 11984260Sobrien#define EL_CAN_ME (EL_FLAGS & TERM_CAN_ME) 120148834Sstefanf#define EL_CAN_UP (EL_FLAGS & TERM_CAN_UP) 12184260Sobrien#define EL_HAS_META (EL_FLAGS & TERM_HAS_META) 12284260Sobrien#define EL_HAS_AUTO_MARGINS (EL_FLAGS & TERM_HAS_AUTO_MARGINS) 12384260Sobrien#define EL_HAS_MAGIC_MARGINS (EL_FLAGS & TERM_HAS_MAGIC_MARGINS) 1241573Srgrimes 125276881Sbapt#endif /* _h_el_terminal */ 126