curses.h revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 1996-2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _CURSES_H
#define _CURSES_H
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* curses.h
*
* XCurses Library
*
* Copyright 1990, 1995 by Mortice Kern Systems Inc. All rights reserved.
*
*/
#include <sys/isa_defs.h>
#include <stdio.h>
#include <term.h>
#include <wchar.h>
#ifdef __cplusplus
extern "C" {
#endif
#define _XOPEN_CURSES
#ifndef EOF
#define EOF (-1)
#endif
#ifndef WEOF
#endif
#define OK 0
#if !(defined(__cplusplus) && defined(_BOOL))
#ifndef _BOOL_DEFINED
typedef short bool;
#define _BOOL_DEFINED
#endif
#endif
#define TRUE 1
#define FALSE 0
typedef unsigned short attr_t;
/*
* These attributes and masks can be applied to an attr_t.
* These are ordered according to the <no_color_video> mask,
* which has been extended to include additional attributes.
*/
#define WA_NORMAL 0x0
#define WA_STANDOUT 0x0001
#define WA_UNDERLINE 0x0002
#define WA_REVERSE 0x0004
#define WA_BLINK 0x0008
#define WA_DIM 0x0010
#define WA_BOLD 0x0020
#define WA_INVIS 0x0040
#define WA_PROTECT 0x0080
#define WA_ALTCHARSET 0x0100
#define WA_HORIZONTAL 0x0200
#define WA_LEFT 0x0400
#define WA_LOW 0x0800
#define WA_RIGHT 0x1000
#define WA_TOP 0x2000
#define WA_VERTICAL 0x4000
/*
* Internal attribute used to support <ceol_standout_glitch>.
*/
#define WA_COOKIE 0x8000
/*
* Color names.
*/
#define COLOR_BLACK 0
#define COLOR_RED 1
#define COLOR_GREEN 2
#define COLOR_YELLOW 3
#define COLOR_BLUE 4
#define COLOR_MAGENTA 5
#define COLOR_CYAN 6
#define COLOR_WHITE 7
/*
* A cchar_t details the attributes, color, and a string of wide characters
* composing a complex character (p12). The wide character string consists
* of a spacing character (wcwidth() > 0) and zero or more non-spacing
* characters. Xcurses (p17) states that the minimum number of non-spacing
* characters associated with a spacing character must be at least 5, if a
* limit is imposed.
*/
#define _M_CCHAR_MAX 6
/*
* Opaque data type.
*/
typedef struct {
short _f; /* True if start of character. */
short _n; /* Number of elements in wc[]. */
short _co; /* Color pair number. */
} cchar_t;
/*
* Opaque data type.
*/
typedef struct window_t {
unsigned short _flags; /* Internal flags for the window. */
unsigned short _scroll; /* Internal for scroll optimization. */
} WINDOW;
/*
* Opaque data type.
*/
typedef struct {
int _kfd; /* typeahead() file descriptor. */
#if defined(_LP64)
unsigned int *_hash; /* Hash values for curscr's screen lines. */
#else
unsigned long *_hash; /* Hash values for curscr's screen lines. */
#endif /* defined(_LP64) */
unsigned short _flags; /* Assorted flags. */
void *_decode; /* Function key decode tree. */
void *_in; /* Wide I/O object. */
struct {
int _size; /* Allocated size of the input stack. */
int _count; /* Number of entries on the input stack. */
int *_stack; /* Buffer used for the input stack. */
} _unget;
struct {
} _slk;
} SCREEN;
/*
* Backwards compatiblity with historical Curses applications.
*/
#ifndef _CHTYPE
#define _CHTYPE
#if defined(_LP64)
typedef unsigned int chtype;
#else
typedef unsigned long chtype;
#endif
#endif
/*
* These attributes and masks can be applied to a chtype.
* They are order according to the <no_color_video> mask.
*/
#if defined(_LP64)
#define A_NORMAL 0x00000000U
#define A_STANDOUT 0x00010000U
#define A_UNDERLINE 0x00020000U
#define A_REVERSE 0x00040000U
#define A_BLINK 0x00080000U
#define A_DIM 0x00100000U
#define A_BOLD 0x00200000U
#define A_INVIS 0x00400000U
#define A_PROTECT 0x00800000U
#define A_ALTCHARSET 0x01000000U
#else /* defined(_LP64) */
#define A_NORMAL 0x00000000UL
#define A_STANDOUT 0x00010000UL
#define A_UNDERLINE 0x00020000UL
#define A_REVERSE 0x00040000UL
#define A_BLINK 0x00080000UL
#define A_DIM 0x00100000UL
#define A_BOLD 0x00200000UL
#define A_INVIS 0x00400000UL
#define A_PROTECT 0x00800000UL
#define A_ALTCHARSET 0x01000000UL
#endif /* defined(_LP64) */
/*
* Color atttribute support for chtype.
*/
#define __COLOR_SHIFT 26
/*
* Characters constants used with a chtype.
* Mapping defined in Xcurses Section 6.2.12 (p260).
*/
/*
* Wide characters constants for a cchar_t.
*/
extern const cchar_t __WACS_VLINE;
extern const cchar_t __WACS_HLINE;
extern const cchar_t __WACS_ULCORNER;
extern const cchar_t __WACS_URCORNER;
extern const cchar_t __WACS_LLCORNER;
extern const cchar_t __WACS_LRCORNER;
extern const cchar_t __WACS_RTEE;
extern const cchar_t __WACS_LTEE;
extern const cchar_t __WACS_BTEE;
extern const cchar_t __WACS_TTEE;
extern const cchar_t __WACS_PLUS;
extern const cchar_t __WACS_DIAMOND;
extern const cchar_t __WACS_CKBOARD;
extern const cchar_t __WACS_DEGREE;
extern const cchar_t __WACS_PLMINUS;
extern const cchar_t __WACS_BULLET;
extern const cchar_t __WACS_LARROW;
extern const cchar_t __WACS_RARROW;
extern const cchar_t __WACS_DARROW;
extern const cchar_t __WACS_UARROW;
extern const cchar_t __WACS_BOARD;
extern const cchar_t __WACS_LANTERN;
extern const cchar_t __WACS_BLOCK;
#define WACS_VLINE &__WACS_VLINE
#define WACS_HLINE &__WACS_HLINE
#define WACS_ULCORNER &__WACS_ULCORNER
#define WACS_URCORNER &__WACS_URCORNER
#define WACS_LLCORNER &__WACS_LLCORNER
#define WACS_LRCORNER &__WACS_LRCORNER
#define WACS_RTEE &__WACS_RTEE
#define WACS_LTEE &__WACS_LTEE
#define WACS_BTEE &__WACS_BTEE
#define WACS_TTEE &__WACS_TTEE
#define WACS_PLUS &__WACS_PLUS
#define WACS_DIAMOND &__WACS_DIAMOND
#define WACS_CKBOARD &__WACS_CKBOARD
#define WACS_DEGREE &__WACS_DEGREE
#define WACS_PLMINUS &__WACS_PLMINUS
#define WACS_BULLET &__WACS_BULLET
#define WACS_LARROW &__WACS_LARROW
#define WACS_RARROW &__WACS_RARROW
#define WACS_DARROW &__WACS_DARROW
#define WACS_UARROW &__WACS_UARROW
#define WACS_BOARD &__WACS_BOARD
#define WACS_LANTERN &__WACS_LANTERN
#define WACS_BLOCK &__WACS_BLOCK
/*
* Internal macros.
*/
/*
* Global Window Macros
*/
/*
* Global variables
*/
extern int COLORS, COLOR_PAIRS;
extern int addnstr(const char *, int);
extern int addstr(const char *);
extern int add_wchnstr(const cchar_t *, int);
extern int add_wchstr(const cchar_t *);
extern int attroff(int);
extern int attron(int);
extern int attrset(int);
extern int baudrate(void);
extern int beep(void);
extern int border(
extern int border_set(
extern bool can_change_color(void);
extern int cbreak(void);
extern int clear(void);
extern int clrtobot(void);
extern int clrtoeol(void);
extern int color_content(short, short *, short *, short *);
extern int COLOR_PAIR(int);
extern int color_set(short, void *);
int, int, int, int, int, int, int);
extern int curs_set(int);
extern int def_prog_mode(void);
extern int def_shell_mode(void);
extern int delay_output(int);
extern int delch(void);
extern int deleteln(void);
extern int doupdate(void);
extern int echo(void);
extern int echo_wchar(const cchar_t *);
extern int endwin(void);
extern char erasechar(void);
extern int erase(void);
extern int erasewchar(wchar_t *);
extern void filter(void);
extern int flash(void);
extern int flushinp(void);
extern int getch(void);
extern int getnstr(char *, int);
extern int getstr(char *);
extern int halfdelay(int);
extern bool has_colors(void);
extern bool has_ic(void);
extern bool has_il(void);
extern int init_color(short, short, short, short);
extern int init_pair(short, short, short);
extern int innstr(char *, int);
extern int insdelln(int);
extern int insertln(void);
extern int insnstr(const char *, int);
extern int insstr(const char *);
extern int instr(char *);
extern int in_wchnstr(cchar_t *, int);
extern bool isendwin(void);
extern bool is_linetouched(WINDOW *, int);
extern bool is_wintouched(WINDOW *);
extern char *keyname(int);
extern char killchar(void);
extern char *longname(void);
extern int move(int, int);
extern int mvaddchnstr(int, int, const chtype *, int);
extern int mvaddchstr(int, int, const chtype *);
extern int mvaddnstr(int, int, const char *, int);
extern int mvaddnwstr(int, int, const wchar_t *, int);
extern int mvaddstr(int, int, const char *);
extern int mvadd_wchnstr(int, int, const cchar_t *, int);
extern int mvadd_wchstr(int, int, const cchar_t *);
extern int mvcur(int, int, int, int);
extern int mvdelch(int, int);
extern int mvgetch(int, int);
extern int mvgetnstr(int, int, char *, int);
extern int mvgetn_wstr(int, int, wint_t *, int);
extern int mvgetstr(int, int, char *);
extern int mvget_wstr(int, int, wint_t *);
extern int mvhline_set(int, int, const cchar_t *, int);
extern int mvinchnstr(int, int, chtype *, int);
extern int mvinnstr(int, int, char *, int);
extern int mvinsnstr(int, int, const char *, int);
extern int mvins_nwstr(int, int, const wchar_t *, int);
extern int mvinsstr(int, int, const char *);
extern int mvinstr(int, int, char *);
extern int mvins_wstr(int, int, const wchar_t *);
extern int mvin_wchnstr(int, int, cchar_t *, int);
extern int mvin_wchstr(int, int, cchar_t *);
extern int mvprintw(int, int, char *, ...);
extern int mvscanw(int, int, char *, ...);
extern int mvvline_set(int, int, const cchar_t *, int);
extern int mvwaddnstr(WINDOW *, int, int, const char *, int);
extern int mvwgetnstr(WINDOW *, int, int, char *, int);
extern int mvwinsnstr(WINDOW *, int, int, const char *, int);
extern int napms(int);
extern int nl(void);
extern int nocbreak(void);
extern int noecho(void);
extern int nonl(void);
extern void noqiflush(void);
extern int noraw(void);
extern int pair_content(short, short *, short *);
extern int PAIR_NUMBER(int);
extern int pnoutrefresh(WINDOW *, int, int, int, int, int, int);
extern int printw(char *, ...);
extern void qiflush(void);
extern int raw(void);
extern int refresh(void);
extern int reset_prog_mode(void);
extern int reset_shell_mode(void);
extern int resetty(void);
extern int ripoffline(int, int (*)(WINDOW *, int));
extern int savetty(void);
extern int scanw(char *, ...);
extern int scr_dump(const char *);
extern int scr_init(const char *);
extern int scrl(int);
extern int scr_restore(const char *);
extern int scr_set(const char *);
short, const void *);
extern int setscrreg(int, int);
extern int slk_attr_off(const attr_t, void *);
extern int slk_attroff(const chtype);
extern int slk_attr_on(const attr_t, void *);
extern int slk_attron(const chtype);
extern int slk_attr_set(const attr_t, short, void *);
extern int slk_attrset(const chtype);
extern int slk_clear(void);
extern int slk_color(short);
extern int slk_init(int);
extern char *slk_label(int);
extern int slk_noutrefresh(void);
extern int slk_refresh(void);
extern int slk_restore(void);
extern int slk_set(int, const char *, int);
extern int slk_touch(void);
extern int standend(void);
extern int standout(void);
extern int start_color(void);
extern attr_t term_attrs(void);
extern char *termname(void);
extern void timeout(int);
extern int typeahead(int);
extern int ungetch(int);
extern int untouchwin(WINDOW *);
extern void use_env(bool);
extern int wborder_set(WINDOW *,
extern void wcursyncup(WINDOW *);
extern int wcolor_set(WINDOW *, short, void *);
extern int wnoutrefresh(WINDOW *);
extern int wsetscrreg(WINDOW *, int, int);
#if !defined(__lint)
/*
* These macros can improve speed and size of an application.
*/
#define mvwadd_wch(w, y, x, cp) \
#define mvaddchnstr(y, x, chs, n) \
#define mvaddchstr(y, x, chs) \
#define mvwaddchnstr(w, y, x, chs, n) \
#define mvwaddchstr(w, y, x, chs) \
#define mvadd_wchnstr(y, x, cp, n) \
#define mvadd_wchstr(y, x, cp) \
#define mvwadd_wchnstr(w, y, x, cp, n) \
#define mvwadd_wchstr(w, y, x, cp) \
#define mvaddnstr(y, x, s, n) \
#define mvaddstr(y, x, s) \
#define mvwaddnstr(w, y, x, s, n) \
#define mvwaddstr(w, y, x, s) \
#define mvaddnwstr(y, x, wcs, n) \
#define mvwaddnwstr(w, y, x, wcs, n) \
#define mvwaddwstr(w, y, x, wcs) \
#define box(w, v, h) \
#define box_set(w, v, h) \
0, 0, 0, 0)
#define can_change_color() \
#define has_colors() (0 < max_colors)
#define wclear(w) \
#define werase(w) \
#define mvwdelch(w, y, x) \
#define wecho_wchar(w, cp) \
#define mvwgetch(w, y, x) \
#define mvwget_wch(w, y, x, wcp) \
#define mvgetnstr(y, x, s, n) \
#define mvgetstr(y, x, s) \
#define mvwgetnstr(w, y, x, s, n) \
#define mvwgetstr(w, y, x, s) \
#define mvgetn_wstr(y, x, wcs, n) \
#define mvget_wstr(y, x, wcs) \
#define mvwgetn_wstr(w, y, x, wcs, n) \
#define mvwget_wstr(w, y, x, wcs) \
#define has_ic() \
#define has_il() \
#define mvhline_set(y, x, cp, n) \
#define mvvline_set(y, x, cp, n) \
#define mvwhline_set(w, y, x, cp, n) \
#define mvwvline_set(w, y, x, cp, n) \
#define mvwinch(w, y, x) \
#define mvinchnstr(y, x, chs, n) \
#define mvwinchnstr(w, y, x, chs, n) \
#define mvwinchstr(w, y, x, chs) \
#define mvin_wchnstr(y, x, cp, n) \
#define mvin_wchstr(y, x, cp) \
#define mvwin_wchnstr(w, y, x, cp, n) \
#define mvwin_wchstr(w, y, x, cp) \
#define mvinnstr(y, x, s, n) \
#define mvinstr(y, x, s) \
#define mvwinnstr(w, y, x, s, n) \
#define mvwinstr(w, y, x, s) \
#define mvwinnwstr(w, y, x, wcs, n) \
#define mvwins_wch(w, y, x, cp) \
#define mvwinsnstr(w, y, x, s, n) \
#define mvwinsstr(w, y, x, s) \
#define mvins_nwstr(y, x, wcs, n) \
#define mvwins_nwstr(w, y, x, wcs, n) \
#define mvwins_wstr(w, y, x, wcs) \
#define is_linetouched(w, y) (0 <= (w)->_last[y])
#endif /* !defined(__lint) */
/*
* Special Keys
*
* Keypad layout
* A1 up A3
* left B2 right
* C1 down C3
*
* Chossing negative values for KEY_ constants means that they can
* be safely returned in either an int or long type.
*/
#define __KEY_BASE (-2)
#define __KEY_MAX __KEY_BASE
#ifdef __cplusplus
}
#endif
#endif /* _CURSES_H */