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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* curses.h
*
* XCurses Library
*
* Copyright 1990, 1995 by Mortice Kern Systems Inc. All rights reserved.
*
*/
#ifndef __M_CURSES_H__
#define __M_CURSES_H__
#define _XOPEN_CURSES
#include <stdio.h>
#include <term.h>
#include <unctrl.h>
#include <wchar.h>
#ifndef EOF
#define EOF (-1)
#endif
#ifndef WEOF
#define WEOF (-1)
#endif
/*
* Not all <wchar.h> are created equal.
*/
#ifndef _MBSTATE_T
#define _MBSTATE_T
typedef int mbstate_t;
#endif
#define OK 0
#if !(defined(__cplusplus) && defined(_BOOL))
typedef short bool;
#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_BLUE 1
#define COLOR_GREEN 2
#define COLOR_CYAN 3
#define COLOR_RED 4
#define COLOR_MAGENTA 5
#define COLOR_YELLOW 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. Keep your grubby mits off.
***/
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. Keep your grubby mits off.
***/
typedef struct window_t {
unsigned short _flags; /* Internal flags for the window. */
unsigned short _scroll; /* Internal for scroll optimization. */
} WINDOW;
/***
*** Opaque data type. Keep your grubby mits off.
***/
typedef struct {
int _kfd; /* typeahead() file descriptor. */
unsigned long *_hash; /* Hash values for curscr's screen lines. */
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;
#ifndef __M_UNCTRL_H__
/*
* Backwards compatiblity with historical Curses applications.
*/
typedef unsigned long chtype;
#endif
/*
* These attributes and masks can be applied to a chtype.
* They are order according to the <no_color_video> mask.
*/
#define A_NORMAL 0x00000000L
#define A_STANDOUT 0x00010000L
#define A_UNDERLINE 0x00020000L
#define A_REVERSE 0x00040000L
#define A_BLINK 0x00080000L
#define A_DIM 0x00100000L
#define A_BOLD 0x00200000L
#define A_INVIS 0x00400000L
#define A_PROTECT 0x00800000L
#define A_ALTCHARSET 0x01000000L
/*
* Colour atttribute support for chtype.
*/
#define __COLOR_SHIFT 26
/*
* Characters constants used with a chtype.
* Mapping defined in Xcurses Section 6.2.12 (p260).
*/
#ifndef _XOPEN_SOURCE
/*
* MKS Extensions for double width box characters.
*/
#define ACS_DVLINE ACS_VLINE
#define ACS_DHLINE ACS_HLINE
#define ACS_DULCORNER ACS_ULCORNER
#define ACS_DURCORNER ACS_URCORNER
#define ACS_DLLCORNER ACS_LLCORNER
#define ACS_DLRCORNER ACS_LRCORNER
#endif /* _XOPEN_SOURCE */
/*
* 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
#ifndef _XOPEN_SOURCE
/*
* MKS Extensions for double width box characters.
*/
#define WACS_DVLINE WACS_VLINE
#define WACS_DHLINE WACS_HLINE
#define WACS_DULCORNER WACS_ULCORNER
#define WACS_DURCORNER WACS_URCORNER
#define WACS_DLLCORNER WACS_LLCORNER
#define WACS_DLRCORNER WACS_LRCORNER
#define WACS_DRTEE WACS_RTEE
#define WACS_DLTEE WACS_LTEE
#define WACS_DBTEE WACS_BTEE
#define WACS_DTTEE WACS_TTEE
#endif /* _XOPEN_SOURCE */
/*
* Internal functions.
*/
extern int __m_outc(int);
extern int __m_tty_wc(int, wchar_t *);
/*
* Internal macros.
*/
/*
* Global Window Macros
*/
/*
* Global variables
*/
extern int COLORS, COLOR_PAIRS;
#ifndef _XOPEN_SOURCE
/*
* Non-portable extension functions.
*/
#endif /* _XOPEN_SOURCE */
#ifdef M_CURSES_TRACE
/*
* Curses trace facility is only available with a version of
* the library that was compiled with -DM_CURSES_TRACE.
*/
extern void traceoff(void);
extern void traceon(void);
#endif /* M_CURSES_TRACE */
extern int add_wchnstr(const cchar_t *, int);
extern int add_wchstr(const cchar_t *);
extern int mvaddchnstr(int, int, const chtype *, int);
extern int mvaddchstr(int, int, const chtype *);
extern int mvadd_wchnstr(int, int, const cchar_t *, int);
extern int mvadd_wchstr(int, int, const cchar_t *);
extern int addnstr(const char *, int);
extern int addstr(const char *);
extern int mvaddnstr(int, int, const char *, int);
extern int mvaddstr(int, int, const char *);
extern int mvaddnwstr(int, int, const wchar_t *, int);
extern int mvwaddnstr(WINDOW *, int, int, const char *, int);
extern int attroff(int);
extern int attron(int);
extern int attrset(int);
extern int color_set(short, void *);
extern int wcolor_set(WINDOW *, short, void *);
extern chtype COLOR_PAIR(short);
extern short PAIR_NUMBER(chtype);
extern int baudrate(void);
extern int delay_output(int);
extern int napms(int);
extern int beep(void);
extern int flash(void);
extern int border(
extern int border_set(
extern int wborder(
WINDOW *,
extern int wborder_set(
WINDOW *,
extern bool can_change_color(void);
extern int color_content(short, short *, short *, short *);
extern bool has_colors(void);
extern int init_color(short, short, short, short);
extern int init_pair(short, short, short);
extern int pair_content(short, short *, short *);
extern int start_color(void);
extern int cbreak(void);
extern int halfdelay(int);
extern int nocbreak(void);
extern int raw(void);
extern int noraw(void);
extern int clear(void);
extern int clrtobot(void);
extern int clrtoeol(void);
extern int erase(void);
extern int curs_set(int);
extern int def_prog_mode(void);
extern int def_shell_mode(void);
extern int reset_prog_mode(void);
extern int reset_shell_mode(void);
extern int delch(void);
extern int mvdelch(int, int);
extern int deleteln(void);
extern int insdelln(int);
extern int insertln(void);
extern int doupdate(void);
extern int refresh(void);
extern int wnoutrefresh(WINDOW *);
extern int echo(void);
extern int noecho(void);
extern int echo_wchar(const cchar_t *);
extern int endwin(void);
extern void filter(void);
extern bool isendwin(void);
extern int ripoffline(int, int (*)(WINDOW *, int));
extern int typeahead(int);
extern void use_env(bool);
extern int erasechar(void);
extern int erasewchar(wchar_t *);
extern int killchar(void);
extern int flushinp(void);
extern int getch(void);
extern int mvgetch(int, int);
extern int getnstr(char *, int);
extern int getstr(char *);
extern int mvgetnstr(int, int, char *, int);
extern int mvgetstr(int, int, char *);
extern int mvwgetnstr(WINDOW *, int, int, char *, int);
extern int mvgetn_wstr(int, int, wint_t *, int);
extern int mvget_wstr(int, int, wint_t *);
extern bool has_ic(void);
extern bool has_il(void);
extern int mvhline_set(int, int, const cchar_t *, int);
extern int mvvline_set(int, int, const cchar_t *, int);
extern int in_wchnstr(cchar_t *, int);
extern int mvinchnstr(int, int, chtype *, int);
extern int mvin_wchnstr(int, int, cchar_t *, int);
extern int mvin_wchstr(int, int, cchar_t *);
extern int innstr(char *, int);
extern int instr(char *);
extern int mvinnstr(int, int, char *, int);
extern int mvinstr(int, int, char *);
extern int insnstr(const char *, int);
extern int insstr(const char *);
extern int mvinsnstr(int, int, const char *, int);
extern int mvinsstr(int, int, const char *);
extern int mvins_nwstr(int, int, const wchar_t *, int);
extern int mvins_wstr(int, int, const wchar_t *);
extern int mvwinsnstr(WINDOW *, int, int, const char *, int);
extern bool is_linetouched(WINDOW *, int);
extern bool is_wintouched(WINDOW *);
extern int untouchwin(WINDOW *);
extern const char *keyname(int);
extern char *longname(void);
extern char *termname(void);
extern int move(int, int);
extern int mvcur(int, int, int, int);
extern int pnoutrefresh(WINDOW *, int, int, int, int, int, int);
extern int nl(void);
extern int nonl(void);
extern int printw(const char *, ...);
extern int mvprintw(int, int, const char *, ...);
#if defined(sun)
#else
#endif
extern void qiflush(void);
extern void noqiflush(void);
extern int resetty(void);
extern int savetty(void);
extern int scanw(const char *, ...);
extern int mvscanw(int, int, const char *, ...);
#if defined(sun)
#else
#endif
extern int scr_dump(const char *);
extern int scr_init(const char *);
extern int scr_restore(const char *);
extern int scr_set(const char *);
extern int scrl(int);
extern int setscrreg(int, int);
extern int wsetscrreg(WINDOW *, int, int);
extern int slk_attroff(const chtype);
extern int slk_attron(const chtype);
extern int slk_attrset(const chtype);
extern int slk_attr_off(const attr_t, void *);
extern int slk_attr_on(const attr_t, void *);
extern int slk_attr_set(const attr_t, short, void *);
extern int slk_color_set(short);
extern int slk_clear(void);
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 attr_t term_attrs(void);
extern void timeout(int);
extern int ungetch(int);
extern void wcursyncup(WINDOW *);
/*
* These macros are not suitable for strict XPG4 conformance,
* because some of them evaluate their arguments more than once.
* However, they can improve speed and size of an application,
* provided an application is careful about not using side effects
*/
#ifndef _XOPEN_SOURCE_EXTENDED
#define wbkgrndset(w,b) ((w)->_bg = *(b))
#define box_set(w,v,h) wborder_set(w,v,v,h,h,0,0,0,0)
&& initialize_color != (char *) 0)
#define has_colors() (0 < max_colors)
#define has_ic() (((insert_character != (char *) 0 \
|| parm_ich != (char *) 0) \
&& (delete_character != (char *) 0 \
|| parm_dch != (char *) 0)) \
|| (enter_insert_mode != (char *) 0 \
&& exit_insert_mode))
#define has_il() (((insert_line != (char *) 0 \
|| parm_insert_line != (char *) 0) \
&& (delete_line != (char *) 0 \
|| parm_delete_line !=(char*)0)) \
|| change_scroll_region != (char *) 0)
#define is_linetouched(w, y) (0 <= (w)->_last[y])
#define overwrite(s, t) __m_copywin(s, t, 0)
(void *)0), 1)
#ifndef _XOPEN_SOURCE
/*
* Obsolete functions names.
*/
#define saveterm def_prog_mode
#define fixterm reset_prog_mode
#define resetterm reset_shell_mode
#endif /* _XOPEN_SOURCE */
#endif /* _XOPEN_SOURCE_EXTENDED */
/*
* 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
#endif /* __M_CURSES_H__ */