1*a2d6b270Schristos /* $NetBSD: terminal.h,v 1.9 2016/05/09 21:46:56 christos Exp $ */ 298c7cbebSchristos 398c7cbebSchristos /*- 498c7cbebSchristos * Copyright (c) 1992, 1993 598c7cbebSchristos * The Regents of the University of California. All rights reserved. 698c7cbebSchristos * 798c7cbebSchristos * This code is derived from software contributed to Berkeley by 898c7cbebSchristos * Christos Zoulas of Cornell University. 998c7cbebSchristos * 1098c7cbebSchristos * Redistribution and use in source and binary forms, with or without 1198c7cbebSchristos * modification, are permitted provided that the following conditions 1298c7cbebSchristos * are met: 1398c7cbebSchristos * 1. Redistributions of source code must retain the above copyright 1498c7cbebSchristos * notice, this list of conditions and the following disclaimer. 1598c7cbebSchristos * 2. Redistributions in binary form must reproduce the above copyright 1698c7cbebSchristos * notice, this list of conditions and the following disclaimer in the 1798c7cbebSchristos * documentation and/or other materials provided with the distribution. 1898c7cbebSchristos * 3. Neither the name of the University nor the names of its contributors 1998c7cbebSchristos * may be used to endorse or promote products derived from this software 2098c7cbebSchristos * without specific prior written permission. 2198c7cbebSchristos * 2298c7cbebSchristos * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2398c7cbebSchristos * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2498c7cbebSchristos * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2598c7cbebSchristos * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2698c7cbebSchristos * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2798c7cbebSchristos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2898c7cbebSchristos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2998c7cbebSchristos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3098c7cbebSchristos * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3198c7cbebSchristos * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3298c7cbebSchristos * SUCH DAMAGE. 3398c7cbebSchristos * 3498c7cbebSchristos * @(#)term.h 8.1 (Berkeley) 6/4/93 3598c7cbebSchristos */ 3698c7cbebSchristos 3798c7cbebSchristos /* 3898c7cbebSchristos * el.term.h: Termcap header 3998c7cbebSchristos */ 4098c7cbebSchristos #ifndef _h_el_terminal 4198c7cbebSchristos #define _h_el_terminal 4298c7cbebSchristos 4398c7cbebSchristos typedef struct { /* Symbolic function key bindings */ 440594af80Schristos const wchar_t *name; /* name of the key */ 4598c7cbebSchristos int key; /* Index in termcap table */ 46d47f9584Schristos keymacro_value_t fun; /* Function bound to it */ 4798c7cbebSchristos int type; /* Type of function */ 48d47f9584Schristos } funckey_t; 4998c7cbebSchristos 5098c7cbebSchristos typedef struct { 5198c7cbebSchristos const char *t_name; /* the terminal name */ 5298c7cbebSchristos coord_t t_size; /* # lines and cols */ 5398c7cbebSchristos int t_flags; 5498c7cbebSchristos #define TERM_CAN_INSERT 0x001 /* Has insert cap */ 5598c7cbebSchristos #define TERM_CAN_DELETE 0x002 /* Has delete cap */ 5698c7cbebSchristos #define TERM_CAN_CEOL 0x004 /* Has CEOL cap */ 5798c7cbebSchristos #define TERM_CAN_TAB 0x008 /* Can use tabs */ 5898c7cbebSchristos #define TERM_CAN_ME 0x010 /* Can turn all attrs. */ 5998c7cbebSchristos #define TERM_CAN_UP 0x020 /* Can move up */ 6098c7cbebSchristos #define TERM_HAS_META 0x040 /* Has a meta key */ 6198c7cbebSchristos #define TERM_HAS_AUTO_MARGINS 0x080 /* Has auto margins */ 6298c7cbebSchristos #define TERM_HAS_MAGIC_MARGINS 0x100 /* Has magic margins */ 6398c7cbebSchristos char *t_buf; /* Termcap buffer */ 64c11bd863Schristos size_t t_loc; /* location used */ 6598c7cbebSchristos char **t_str; /* termcap strings */ 6698c7cbebSchristos int *t_val; /* termcap values */ 6798c7cbebSchristos char *t_cap; /* Termcap buffer */ 68d47f9584Schristos funckey_t *t_fkey; /* Array of keys */ 6998c7cbebSchristos } el_terminal_t; 7098c7cbebSchristos 7198c7cbebSchristos /* 7298c7cbebSchristos * fKey indexes 7398c7cbebSchristos */ 7498c7cbebSchristos #define A_K_DN 0 7598c7cbebSchristos #define A_K_UP 1 7698c7cbebSchristos #define A_K_LT 2 7798c7cbebSchristos #define A_K_RT 3 7898c7cbebSchristos #define A_K_HO 4 7998c7cbebSchristos #define A_K_EN 5 80fac360ffSchristos #define A_K_DE 6 81fac360ffSchristos #define A_K_NKEYS 7 8298c7cbebSchristos 83*a2d6b270Schristos libedit_private void terminal_move_to_line(EditLine *, int); 84*a2d6b270Schristos libedit_private void terminal_move_to_char(EditLine *, int); 85*a2d6b270Schristos libedit_private void terminal_clear_EOL(EditLine *, int); 86*a2d6b270Schristos libedit_private void terminal_overwrite(EditLine *, const wchar_t *, size_t); 87*a2d6b270Schristos libedit_private void terminal_insertwrite(EditLine *, wchar_t *, int); 88*a2d6b270Schristos libedit_private void terminal_deletechars(EditLine *, int); 89*a2d6b270Schristos libedit_private void terminal_clear_screen(EditLine *); 90*a2d6b270Schristos libedit_private void terminal_beep(EditLine *); 91*a2d6b270Schristos libedit_private int terminal_change_size(EditLine *, int, int); 92*a2d6b270Schristos libedit_private int terminal_get_size(EditLine *, int *, int *); 93*a2d6b270Schristos libedit_private int terminal_init(EditLine *); 94*a2d6b270Schristos libedit_private void terminal_bind_arrow(EditLine *); 95*a2d6b270Schristos libedit_private void terminal_print_arrow(EditLine *, const wchar_t *); 96*a2d6b270Schristos libedit_private int terminal_clear_arrow(EditLine *, const wchar_t *); 97*a2d6b270Schristos libedit_private int terminal_set_arrow(EditLine *, const wchar_t *, 980594af80Schristos keymacro_value_t *, int); 99*a2d6b270Schristos libedit_private void terminal_end(EditLine *); 100*a2d6b270Schristos libedit_private void terminal_get(EditLine *, const char **); 101*a2d6b270Schristos libedit_private int terminal_set(EditLine *, const char *); 102*a2d6b270Schristos libedit_private int terminal_settc(EditLine *, int, const wchar_t **); 103*a2d6b270Schristos libedit_private int terminal_gettc(EditLine *, int, char **); 104*a2d6b270Schristos libedit_private int terminal_telltc(EditLine *, int, const wchar_t **); 105*a2d6b270Schristos libedit_private int terminal_echotc(EditLine *, int, const wchar_t **); 106*a2d6b270Schristos libedit_private void terminal_writec(EditLine *, wint_t); 107*a2d6b270Schristos libedit_private int terminal__putc(EditLine *, wint_t); 108*a2d6b270Schristos libedit_private void terminal__flush(EditLine *); 10998c7cbebSchristos 11098c7cbebSchristos /* 11198c7cbebSchristos * Easy access macros 11298c7cbebSchristos */ 11398c7cbebSchristos #define EL_FLAGS (el)->el_terminal.t_flags 11498c7cbebSchristos 11598c7cbebSchristos #define EL_CAN_INSERT (EL_FLAGS & TERM_CAN_INSERT) 11698c7cbebSchristos #define EL_CAN_DELETE (EL_FLAGS & TERM_CAN_DELETE) 11798c7cbebSchristos #define EL_CAN_CEOL (EL_FLAGS & TERM_CAN_CEOL) 11898c7cbebSchristos #define EL_CAN_TAB (EL_FLAGS & TERM_CAN_TAB) 11998c7cbebSchristos #define EL_CAN_ME (EL_FLAGS & TERM_CAN_ME) 12098c7cbebSchristos #define EL_CAN_UP (EL_FLAGS & TERM_CAN_UP) 12198c7cbebSchristos #define EL_HAS_META (EL_FLAGS & TERM_HAS_META) 12298c7cbebSchristos #define EL_HAS_AUTO_MARGINS (EL_FLAGS & TERM_HAS_AUTO_MARGINS) 12398c7cbebSchristos #define EL_HAS_MAGIC_MARGINS (EL_FLAGS & TERM_HAS_MAGIC_MARGINS) 12498c7cbebSchristos 12598c7cbebSchristos #endif /* _h_el_terminal */ 126