1*12db70c8Szrj /* $NetBSD: terminal.h,v 1.9 2016/05/09 21:46:56 christos Exp $ */ 232fe07f8SJohn Marino 332fe07f8SJohn Marino /*- 432fe07f8SJohn Marino * Copyright (c) 1992, 1993 532fe07f8SJohn Marino * The Regents of the University of California. All rights reserved. 632fe07f8SJohn Marino * 732fe07f8SJohn Marino * This code is derived from software contributed to Berkeley by 832fe07f8SJohn Marino * Christos Zoulas of Cornell University. 932fe07f8SJohn Marino * 1032fe07f8SJohn Marino * Redistribution and use in source and binary forms, with or without 1132fe07f8SJohn Marino * modification, are permitted provided that the following conditions 1232fe07f8SJohn Marino * are met: 1332fe07f8SJohn Marino * 1. Redistributions of source code must retain the above copyright 1432fe07f8SJohn Marino * notice, this list of conditions and the following disclaimer. 1532fe07f8SJohn Marino * 2. Redistributions in binary form must reproduce the above copyright 1632fe07f8SJohn Marino * notice, this list of conditions and the following disclaimer in the 1732fe07f8SJohn Marino * documentation and/or other materials provided with the distribution. 1832fe07f8SJohn Marino * 3. Neither the name of the University nor the names of its contributors 1932fe07f8SJohn Marino * may be used to endorse or promote products derived from this software 2032fe07f8SJohn Marino * without specific prior written permission. 2132fe07f8SJohn Marino * 2232fe07f8SJohn Marino * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2332fe07f8SJohn Marino * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2432fe07f8SJohn Marino * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2532fe07f8SJohn Marino * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2632fe07f8SJohn Marino * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2732fe07f8SJohn Marino * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2832fe07f8SJohn Marino * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2932fe07f8SJohn Marino * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3032fe07f8SJohn Marino * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3132fe07f8SJohn Marino * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3232fe07f8SJohn Marino * SUCH DAMAGE. 3332fe07f8SJohn Marino * 3432fe07f8SJohn Marino * @(#)term.h 8.1 (Berkeley) 6/4/93 3532fe07f8SJohn Marino */ 3632fe07f8SJohn Marino 3732fe07f8SJohn Marino /* 3832fe07f8SJohn Marino * el.term.h: Termcap header 3932fe07f8SJohn Marino */ 4032fe07f8SJohn Marino #ifndef _h_el_terminal 4132fe07f8SJohn Marino #define _h_el_terminal 4232fe07f8SJohn Marino 4332fe07f8SJohn Marino typedef struct { /* Symbolic function key bindings */ 44*12db70c8Szrj const wchar_t *name; /* name of the key */ 4532fe07f8SJohn Marino int key; /* Index in termcap table */ 4632fe07f8SJohn Marino keymacro_value_t fun; /* Function bound to it */ 4732fe07f8SJohn Marino int type; /* Type of function */ 4832fe07f8SJohn Marino } funckey_t; 4932fe07f8SJohn Marino 5032fe07f8SJohn Marino typedef struct { 5132fe07f8SJohn Marino const char *t_name; /* the terminal name */ 5232fe07f8SJohn Marino coord_t t_size; /* # lines and cols */ 5332fe07f8SJohn Marino int t_flags; 5432fe07f8SJohn Marino #define TERM_CAN_INSERT 0x001 /* Has insert cap */ 5532fe07f8SJohn Marino #define TERM_CAN_DELETE 0x002 /* Has delete cap */ 5632fe07f8SJohn Marino #define TERM_CAN_CEOL 0x004 /* Has CEOL cap */ 5732fe07f8SJohn Marino #define TERM_CAN_TAB 0x008 /* Can use tabs */ 5832fe07f8SJohn Marino #define TERM_CAN_ME 0x010 /* Can turn all attrs. */ 5932fe07f8SJohn Marino #define TERM_CAN_UP 0x020 /* Can move up */ 6032fe07f8SJohn Marino #define TERM_HAS_META 0x040 /* Has a meta key */ 6132fe07f8SJohn Marino #define TERM_HAS_AUTO_MARGINS 0x080 /* Has auto margins */ 6232fe07f8SJohn Marino #define TERM_HAS_MAGIC_MARGINS 0x100 /* Has magic margins */ 6332fe07f8SJohn Marino char *t_buf; /* Termcap buffer */ 6432fe07f8SJohn Marino size_t t_loc; /* location used */ 6532fe07f8SJohn Marino char **t_str; /* termcap strings */ 6632fe07f8SJohn Marino int *t_val; /* termcap values */ 6732fe07f8SJohn Marino char *t_cap; /* Termcap buffer */ 6832fe07f8SJohn Marino funckey_t *t_fkey; /* Array of keys */ 6932fe07f8SJohn Marino } el_terminal_t; 7032fe07f8SJohn Marino 7132fe07f8SJohn Marino /* 7232fe07f8SJohn Marino * fKey indexes 7332fe07f8SJohn Marino */ 7432fe07f8SJohn Marino #define A_K_DN 0 7532fe07f8SJohn Marino #define A_K_UP 1 7632fe07f8SJohn Marino #define A_K_LT 2 7732fe07f8SJohn Marino #define A_K_RT 3 7832fe07f8SJohn Marino #define A_K_HO 4 7932fe07f8SJohn Marino #define A_K_EN 5 80c8e4d2bfSJohn Marino #define A_K_DE 6 81c8e4d2bfSJohn Marino #define A_K_NKEYS 7 8232fe07f8SJohn Marino 8332fe07f8SJohn Marino #ifdef __sun 8432fe07f8SJohn Marino extern int tgetent(char *, const char *); 8532fe07f8SJohn Marino extern int tgetflag(char *); 8632fe07f8SJohn Marino extern int tgetnum(char *); 8732fe07f8SJohn Marino extern int tputs(const char *, int, int (*)(int)); 8832fe07f8SJohn Marino extern char* tgoto(const char*, int, int); 8932fe07f8SJohn Marino extern char* tgetstr(char*, char**); 9032fe07f8SJohn Marino #endif 9132fe07f8SJohn Marino 92*12db70c8Szrj libedit_private void terminal_move_to_line(EditLine *, int); 93*12db70c8Szrj libedit_private void terminal_move_to_char(EditLine *, int); 94*12db70c8Szrj libedit_private void terminal_clear_EOL(EditLine *, int); 95*12db70c8Szrj libedit_private void terminal_overwrite(EditLine *, const wchar_t *, size_t); 96*12db70c8Szrj libedit_private void terminal_insertwrite(EditLine *, wchar_t *, int); 97*12db70c8Szrj libedit_private void terminal_deletechars(EditLine *, int); 98*12db70c8Szrj libedit_private void terminal_clear_screen(EditLine *); 99*12db70c8Szrj libedit_private void terminal_beep(EditLine *); 100*12db70c8Szrj libedit_private int terminal_change_size(EditLine *, int, int); 101*12db70c8Szrj libedit_private int terminal_get_size(EditLine *, int *, int *); 102*12db70c8Szrj libedit_private int terminal_init(EditLine *); 103*12db70c8Szrj libedit_private void terminal_bind_arrow(EditLine *); 104*12db70c8Szrj libedit_private void terminal_print_arrow(EditLine *, const wchar_t *); 105*12db70c8Szrj libedit_private int terminal_clear_arrow(EditLine *, const wchar_t *); 106*12db70c8Szrj libedit_private int terminal_set_arrow(EditLine *, const wchar_t *, 107*12db70c8Szrj keymacro_value_t *, int); 108*12db70c8Szrj libedit_private void terminal_end(EditLine *); 109*12db70c8Szrj libedit_private void terminal_get(EditLine *, const char **); 110*12db70c8Szrj libedit_private int terminal_set(EditLine *, const char *); 111*12db70c8Szrj libedit_private int terminal_settc(EditLine *, int, const wchar_t **); 112*12db70c8Szrj libedit_private int terminal_gettc(EditLine *, int, char **); 113*12db70c8Szrj libedit_private int terminal_telltc(EditLine *, int, const wchar_t **); 114*12db70c8Szrj libedit_private int terminal_echotc(EditLine *, int, const wchar_t **); 115*12db70c8Szrj libedit_private void terminal_writec(EditLine *, wint_t); 116*12db70c8Szrj libedit_private int terminal__putc(EditLine *, wint_t); 117*12db70c8Szrj libedit_private void terminal__flush(EditLine *); 11832fe07f8SJohn Marino 11932fe07f8SJohn Marino /* 12032fe07f8SJohn Marino * Easy access macros 12132fe07f8SJohn Marino */ 12232fe07f8SJohn Marino #define EL_FLAGS (el)->el_terminal.t_flags 12332fe07f8SJohn Marino 12432fe07f8SJohn Marino #define EL_CAN_INSERT (EL_FLAGS & TERM_CAN_INSERT) 12532fe07f8SJohn Marino #define EL_CAN_DELETE (EL_FLAGS & TERM_CAN_DELETE) 12632fe07f8SJohn Marino #define EL_CAN_CEOL (EL_FLAGS & TERM_CAN_CEOL) 12732fe07f8SJohn Marino #define EL_CAN_TAB (EL_FLAGS & TERM_CAN_TAB) 12832fe07f8SJohn Marino #define EL_CAN_ME (EL_FLAGS & TERM_CAN_ME) 12932fe07f8SJohn Marino #define EL_CAN_UP (EL_FLAGS & TERM_CAN_UP) 13032fe07f8SJohn Marino #define EL_HAS_META (EL_FLAGS & TERM_HAS_META) 13132fe07f8SJohn Marino #define EL_HAS_AUTO_MARGINS (EL_FLAGS & TERM_HAS_AUTO_MARGINS) 13232fe07f8SJohn Marino #define EL_HAS_MAGIC_MARGINS (EL_FLAGS & TERM_HAS_MAGIC_MARGINS) 13332fe07f8SJohn Marino 13432fe07f8SJohn Marino #endif /* _h_el_terminal */ 135