* ========== Copyright Header Begin ==========================================
* Hypervisor Software File: termcap.c
* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
* - Do no alter or remove copyright notices
* - Redistribution and use of this software in source and binary forms, with
* or without modification, are permitted provided that the following
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of Sun Microsystems, Inc. or the names of contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
* INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
* MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
* ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
* DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
* OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
* FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
* DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
* SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
* You acknowledge that this software is not designed, licensed or
* intended for use in the design, construction, operation or maintenance of
* ========== Copyright Header End ============================================
* Copyright 1985-1990 Bradley Forthware
* Copyright 1990-2001 Sun Microsystems, Inc. All Rights Reserved
* Interface to the Unix "termcap" facility for use by Forthmacs running
* under the C wrapper program.
* int t_init() Called once to initialize things. Returns 0 if
* okay, nonzero if an error occurred.
* t_op(op) "Generic" no-arguments terminal operation. Op is
* a number between 0 and 12, corresponding to an
* operation in the "opnames" table.
* t_move(col, row) Move the cursor to the indicated postion. (0 origin)
* int t_rows() The number of rows (lines) on the terminal screen
* int t_cols() The number of columns on the terminal screen
"ic", /* 4 insert char */
"dc", /* 5 delete char */
"ce", /* 6 clear rest of line */
"cd", /* 7 clear rest of screen */
"al", /* 8 insert line */
"dl", /* 9 delete line */
"cl", /* 10 clear screen */
"so", /* 11 start stand-out mode */
"se", /* 12 end stand-out mode */
"cm", /* 13 move cursor */
#define PUTC ((int (*)(char))putchar)
tputs(opstrings
[op
], 1, PUTC
);
tputs(tgoto(opstrings
[13], col
, row
), 1, PUTC
);
if ((tv_stype
= getenv("TERM")) == 0) {
putstring("Environment variable TERM not defined!\n");
if ((tgetent(tcbuf
, tv_stype
)) != 1) {
putstring("Unknown terminal type ");
if ((tgetent(tcbuf
, "dumb")) != 1) /* Default to "dumb" */
/* Entry 0 (left) is a special case */
t
= tgetstr(opnames
[i
], &p
);
opstrings
[i
] = t
? t
: "";
/* Unfortunately, the tty driver may turn the lf into crlf. Sigh. */
if (*opstrings
[3] == '\0')
if ((num
= tgetnum("li")) != -1)
if ((num
= tgetnum("co")) != -1)
if (p
>= &tcapbuf
[TCAPSLEN
]) {
putstring("Terminal description too big!\n");