/****************************************************************************
- * Copyright (c) 1998-2012,2013 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2013,2014 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
****************************************************************************/
/*
- * $Id: curses.priv.h,v 1.521 2013/01/12 21:53:35 tom Exp $
+ * $Id: curses.priv.h,v 1.544 2014/10/11 19:30:58 tom Exp $
*
* curses.priv.h
*
#include <errno.h>
+#if defined __hpux
+# ifndef EILSEQ
+# define EILSEQ 47
+# endif
+#endif
+
#ifndef PATH_MAX
# if defined(_POSIX_PATH_MAX)
# define PATH_MAX _POSIX_PATH_MAX
#define USE_SIGWINCH 0
#endif
+/*
+ * When building in the MSYS2 environment, the automatic discovery of
+ * the path separator in configure doesn't work properly. So, if building
+ * for MinGW, we enforce the correct Windows PATH separator
+ */
+#ifdef __MINGW32__
+# ifdef NCURSES_PATHSEP
+# undef NCURSES_PATHSEP
+# endif
+# define NCURSES_PATHSEP ';'
+#endif
+
/*
* If desired, one can configure this, disabling environment variables that
* point to custom terminfo/termcap locations.
extern NCURSES_EXPORT(int) _nc_env_access (void);
#endif
+/*
+ * Not all platforms have memmove; some have an equivalent bcopy. (Some may
+ * have neither).
+ */
+#if USE_OK_BCOPY
+#define memmove(d,s,n) bcopy(s,d,n)
+#elif USE_MY_MEMMOVE
+#define memmove(d,s,n) _nc_memmove(d,s,n)
+extern NCURSES_EXPORT(void *) _nc_memmove (void *, const void *, size_t);
+#endif
+
/*
* If we have va_copy(), use it for assigning va_list's.
*/
* Structure for palette tables
*/
-typedef struct
-{
- short red, green, blue; /* what color_content() returns */
- short r, g, b; /* params to init_color() */
- int init; /* true if we called init_color() */
-}
-color_t;
-
#define MAXCOLUMNS 135
#define MAXLINES 66
#define FIFO_SIZE MAXCOLUMNS+2 /* for nocbreak mode input */
#undef _XOPEN_SOURCE_EXTENDED
#undef _XPG5
#define _nc_bkgd _bkgd
-#define wgetbkgrnd(win, wch) *wch = win->_bkgd
+#define wgetbkgrnd(win, wch) ((*wch = win->_bkgd) != 0 ? OK : ERR)
#define wbkgrnd wbkgd
#endif
#include <curses.h> /* we'll use -Ipath directive to get the right one! */
+typedef struct
+{
+ NCURSES_COLOR_T red, green, blue; /* what color_content() returns */
+ NCURSES_COLOR_T r, g, b; /* params to init_color() */
+ int init; /* true if we called init_color() */
+}
+color_t;
+
/*
* If curses.h did not expose the SCREEN-functions, then we do not need the
* parameter in the corresponding unextended functions.
#define HasTerminal(sp) (((sp) != 0) && (0 != ((sp)->_term)))
#define IsValidScreen(sp) (HasTerminal(sp) && !IsPreScreen(sp))
-#if BROKEN_LINKER || USE_REENTRANT
+#if USE_REENTRANT
#define CurTerm _nc_prescreen._cur_term
#else
#define CurTerm cur_term
#include <nc_tparm.h>
+/*
+ * Simplify ifdef's for the "*_ATTR" macros in case italics are not configured.
+ */
+#ifdef A_ITALIC
+#define USE_ITALIC 1
+#else
+#define USE_ITALIC 0
+#define A_ITALIC 0
+#endif
+
/*
* Use these macros internally, to make tracing less verbose. But leave the
* option for compiling the tracing into the library.
#endif
} MouseType;
+typedef enum {
+ MF_X10 = 0 /* conventional 3-byte format */
+ , MF_SGR1006 /* xterm private mode 1006, SGR-style */
+#ifdef EXP_XTERM_1005
+ , MF_XTERM_1005 /* xterm UTF-8 private mode 1005 */
+#endif
+} MouseFormat;
+
/*
* Structures for scrolling.
*/
char *first_name;
char **keyname_table;
+ int init_keyname;
int slk_format;
/* used in lib_vidattr.c */
bool _use_rmso; /* true if we may use 'rmso' */
bool _use_rmul; /* true if we may use 'rmul' */
+#if USE_ITALIC
+ bool _use_ritm; /* true if we may use 'ritm' */
+#endif
#if USE_KLIBC_KBD
bool _extended_key; /* true if an extended key */
mmask_t _mouse_mask; /* set via mousemask() */
mmask_t _mouse_mask2; /* OR's in press/release bits */
mmask_t _mouse_bstate;
+ MouseFormat _mouse_format; /* type of xterm mouse protocol */
NCURSES_CONST char *_mouse_xtermcap; /* string to enable/disable mouse */
MEVENT _mouse_events[EV_MAX]; /* hold the last mouse event seen */
MEVENT *_mouse_eventp; /* next free slot in event queue */
#define UChar(c) ((unsigned char)(c))
#define UShort(c) ((unsigned short)(c))
-#define ChCharOf(c) ((c) & (chtype)A_CHARTEXT)
-#define ChAttrOf(c) ((c) & (chtype)A_ATTRIBUTES)
+#define ChCharOf(c) ((chtype)(c) & (chtype)A_CHARTEXT)
+#define ChAttrOf(c) ((chtype)(c) & (chtype)A_ATTRIBUTES)
#ifndef MB_LEN_MAX
#define MB_LEN_MAX 8 /* should be >= MB_CUR_MAX, but that may be a function */
AttrOf(dst) |= (attr_t) (ext + 1)
#define if_WIDEC(code) code
-#define Charable(ch) ((SP_PARM->_legacy_coding) \
+#define Charable(ch) (((SP_PARM->_legacy_coding) \
|| (AttrOf(ch) & A_ALTCHARSET) \
- || (!isWidecExt(ch) && \
+ || (!isWidecExt(ch))) && \
(ch).chars[1] == L'\0' && \
- _nc_is_charable(CharOf(ch))))
+ _nc_is_charable(CharOf(ch)))
#define L(ch) L ## ch
#else /* }{ */
NCURSES_EXPORT(void) name (void) { }
#define ALL_BUT_COLOR ((chtype)~(A_COLOR))
-#define NONBLANK_ATTR (A_NORMAL|A_BOLD|A_DIM|A_BLINK)
+#define NONBLANK_ATTR (A_BOLD | A_DIM | A_BLINK | A_ITALIC)
+#define TPARM_ATTR (A_STANDOUT | A_UNDERLINE | A_REVERSE | A_BLINK | A_DIM | A_BOLD | A_ALTCHARSET | A_INVIS | A_PROTECT)
+#define XMC_CONFLICT (A_STANDOUT | A_UNDERLINE | A_REVERSE | A_BLINK | A_DIM | A_BOLD | A_INVIS | A_PROTECT | A_ITALIC)
#define XMC_CHANGES(c) ((c) & SP_PARM->_xmc_suppress)
#define toggle_attr_on(S,at) {\
extern NCURSES_EXPORT(char *) _nc_trace_bufcat (int, const char *);
extern NCURSES_EXPORT(char *) _nc_tracechar (SCREEN *, int);
extern NCURSES_EXPORT(char *) _nc_tracemouse (SCREEN *, MEVENT const *);
+extern NCURSES_EXPORT(char *) _nc_trace_mmask_t (SCREEN *, mmask_t);
extern NCURSES_EXPORT(int) _nc_access (const char *, int);
extern NCURSES_EXPORT(int) _nc_baudrate (int);
extern NCURSES_EXPORT(int) _nc_freewin (WINDOW *);
#define USE_SETBUF_0 0
-#define NC_BUFFERED(sp,flag) NCURSES_SP_NAME(_nc_set_buffer)(NCURSES_SP_ARGx sp->_ofp, flag)
-
#define NC_OUTPUT(sp) ((sp != 0) ? sp->_ofp : stdout)
/*
sp->jump = outc
#ifdef USE_TERM_DRIVER
-typedef void* TERM_HANDLE;
typedef struct _termInfo
{
typedef struct term_driver {
bool isTerminfo;
- bool (*CanHandle)(struct DriverTCB*, const char*, int*);
- void (*init)(struct DriverTCB*);
- void (*release)(struct DriverTCB*);
- int (*size)(struct DriverTCB*, int* Line, int *Cols);
- int (*sgmode)(struct DriverTCB*, int setFlag, TTY*);
- chtype (*conattr)(struct DriverTCB*);
- int (*hwcur)(struct DriverTCB*, int yold, int xold, int y, int x);
- int (*mode)(struct DriverTCB*, int progFlag, int defFlag);
- bool (*rescol)(struct DriverTCB*);
- bool (*rescolors)(struct DriverTCB*);
- void (*color)(struct DriverTCB*, int fore, int color, int(*)(SCREEN*, int));
- int (*doBeepOrFlash)(struct DriverTCB*, int);
- void (*initpair)(struct DriverTCB*, int, int, int);
- void (*initcolor)(struct DriverTCB*, int, int, int, int);
- void (*docolor)(struct DriverTCB*, int, int, int, int(*)(SCREEN*, int));
- void (*initmouse)(struct DriverTCB*);
- int (*testmouse)(struct DriverTCB*, int EVENTLIST_2nd(_nc_eventlist*));
- void (*setfilter)(struct DriverTCB*);
- void (*hwlabel)(struct DriverTCB*, int, char*);
- void (*hwlabelOnOff)(struct DriverTCB*, int);
- int (*update)(struct DriverTCB*);
- int (*defaultcolors)(struct DriverTCB*, int, int);
- int (*print)(struct DriverTCB*, char*, int);
- int (*getsize)(struct DriverTCB*, int*, int*);
- int (*setsize)(struct DriverTCB*, int, int);
- void (*initacs)(struct DriverTCB*, chtype*, chtype*);
- void (*scinit)(SCREEN *);
- void (*scexit)(SCREEN *);
- int (*twait)(struct DriverTCB*, int, int, int* EVENTLIST_2nd(_nc_eventlist*));
- int (*read)(struct DriverTCB*, int*);
- int (*nap)(struct DriverTCB*, int);
- int (*kpad)(struct DriverTCB*, int);
- int (*kyOk)(struct DriverTCB*, int, int);
- bool (*kyExist)(struct DriverTCB*, int);
+ const char* (*td_name)(struct DriverTCB*);
+ bool (*td_CanHandle)(struct DriverTCB*, const char*, int*);
+ void (*td_init)(struct DriverTCB*);
+ void (*td_release)(struct DriverTCB*);
+ int (*td_size)(struct DriverTCB*, int* Line, int *Cols);
+ int (*td_sgmode)(struct DriverTCB*, int setFlag, TTY*);
+ chtype (*td_conattr)(struct DriverTCB*);
+ int (*td_hwcur)(struct DriverTCB*, int yold, int xold, int y, int x);
+ int (*td_mode)(struct DriverTCB*, int progFlag, int defFlag);
+ bool (*td_rescol)(struct DriverTCB*);
+ bool (*td_rescolors)(struct DriverTCB*);
+ void (*td_color)(struct DriverTCB*, int fore, int color, int(*)(SCREEN*, int));
+ int (*td_doBeepOrFlash)(struct DriverTCB*, int);
+ void (*td_initpair)(struct DriverTCB*, int, int, int);
+ void (*td_initcolor)(struct DriverTCB*, int, int, int, int);
+ void (*td_docolor)(struct DriverTCB*, int, int, int, int(*)(SCREEN*, int));
+ void (*td_initmouse)(struct DriverTCB*);
+ int (*td_testmouse)(struct DriverTCB*, int EVENTLIST_2nd(_nc_eventlist*));
+ void (*td_setfilter)(struct DriverTCB*);
+ void (*td_hwlabel)(struct DriverTCB*, int, char*);
+ void (*td_hwlabelOnOff)(struct DriverTCB*, int);
+ int (*td_update)(struct DriverTCB*);
+ int (*td_defaultcolors)(struct DriverTCB*, int, int);
+ int (*td_print)(struct DriverTCB*, char*, int);
+ int (*td_getsize)(struct DriverTCB*, int*, int*);
+ int (*td_setsize)(struct DriverTCB*, int, int);
+ void (*td_initacs)(struct DriverTCB*, chtype*, chtype*);
+ void (*td_scinit)(SCREEN *);
+ void (*td_scexit)(SCREEN *);
+ int (*td_twait)(struct DriverTCB*, int, int, int* EVENTLIST_2nd(_nc_eventlist*));
+ int (*td_read)(struct DriverTCB*, int*);
+ int (*td_nap)(struct DriverTCB*, int);
+ int (*td_kpad)(struct DriverTCB*, int);
+ int (*td_kyOk)(struct DriverTCB*, int, int);
+ bool (*td_kyExist)(struct DriverTCB*, int);
+ int (*td_cursorSet)(struct DriverTCB*, int);
} TERM_DRIVER;
typedef struct DriverTCB
{
TERMINAL term; /* needs to be the first Element !!! */
- TERM_HANDLE inp; /* The input handle of the Terminal */
- TERM_HANDLE out; /* The output handle of the Terminal in shell mode */
- TERM_HANDLE hdl; /* The output handle of the Terminal in prog mode */
TERM_DRIVER* drv; /* The driver for that Terminal */
SCREEN* csp; /* The screen that owns that Terminal */
TerminalInfo info; /* Driver independent core capabilities of the Terminal */
#ifdef __MINGW32__
#include <nc_mingw.h>
extern NCURSES_EXPORT_VAR(TERM_DRIVER) _nc_WIN_DRIVER;
+extern NCURSES_EXPORT(int) _nc_mingw_isatty(int fd);
+extern NCURSES_EXPORT(int) _nc_mingw_isconsole(int fd);
+extern NCURSES_EXPORT(int) _nc_mingw_console_read(
+ SCREEN *sp,
+ HANDLE fd,
+ int *buf);
+extern NCURSES_EXPORT(int) _nc_mingw_testmouse(
+ SCREEN * sp,
+ HANDLE fd,
+ int delay);
+#else
#endif
extern NCURSES_EXPORT_VAR(TERM_DRIVER) _nc_TINFO_DRIVER;
#endif
+#if defined(USE_TERM_DRIVER) && defined(__MINGW32__)
+#define NC_ISATTY(fd) _nc_mingw_isatty(fd)
+#else
+#define NC_ISATTY(fd) isatty(fd)
+#endif
+
#ifdef USE_TERM_DRIVER
-#define IsTermInfo(sp) (TCBOf(sp) && ((TCBOf(sp)->drv->isTerminfo)))
+# define IsTermInfo(sp) ((TCBOf(sp) != 0) && ((TCBOf(sp)->drv->isTerminfo)))
+# define HasTInfoTerminal(sp) ((0 != TerminalOf(sp)) && IsTermInfo(sp))
+# ifdef __MINGW32__
+# define IsTermInfoOnConsole(sp) (IsTermInfo(sp)&&_nc_mingw_isconsole(TerminalOf(sp)->Filedes))
+#else
+# define IsTermInfoOnConsole(sp) FALSE
+# endif
#else
-#define IsTermInfo(sp) TRUE
+# define IsTermInfo(sp) TRUE
+# define HasTInfoTerminal(sp) (0 != TerminalOf(sp))
+# define IsTermInfoOnConsole(sp) FALSE
#endif
-#define HasTInfoTerminal(sp) ((0 != TerminalOf(sp)) && IsTermInfo(sp))
#define IsValidTIScreen(sp) (HasTInfoTerminal(sp))
/*
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_setupscreen)(SCREEN**, int, int, FILE *, int, int);
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_tgetent)(SCREEN*,char*,const char *);
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_tigetnum)(SCREEN*,NCURSES_CONST char*);
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_vid_attr)(SCREEN *, attr_t, short, void *);
+extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_vid_attr)(SCREEN *, attr_t, NCURSES_COLOR_T, void *);
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_vidputs)(SCREEN*,chtype,int(*) (SCREEN*, int));
extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_do_color)(SCREEN*, int, int, int, NCURSES_SP_OUTC);
extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_do_xmc_glitch)(SCREEN*, attr_t);
#endif
+#ifdef EXP_XTERM_1005
+NCURSES_EXPORT(int) _nc_conv_to_utf8(unsigned char *, unsigned, unsigned);
+NCURSES_EXPORT(int) _nc_conv_to_utf32(unsigned *, const char *, unsigned);
+#endif
+
#ifdef __cplusplus
}
#endif