mirror of
https://github.com/Aigor44/ncursesw-morphos.git
synced 2025-01-06 14:44:25 +08:00
3eda6f30a8
+ minor fixes for vt100+4bsd, e.g., delay in sgr for consistency -TD + add smso for env230, to match sgr -TD + remove p7/protect from sgr in fbterm -TD + drop setf/setb from fbterm; setaf/setab are enough -TD + make xterm-pcolor sgr consistent with other capabilities -TD + add rmxx/smxx ECMA-48 strikeout extension to tmux and xterm-basic (discussion with Nicholas Marriott) + add test-programs sp_tinfo and extended_color + modify no-leaks code for lib_cur_term.c to account for the tgetent() cache. + modify setupterm() to save original tty-modes so that erasechar() works as expected. Also modify _nc_setupscreen() to avoid redundant calls to get original tty-modes. + modify set_curterm() to update ttytype[] data used by longname(). + modify wattr_set() and wattr_get() to return ERR if win-parameter is null, as documented. + improve cast used for null-pointer checks in header macros, to reduce compiler warnings. + modify several functions, using the reserved "opts" parameter to pass color- and pair-values larger than 16-bits: + getcchar(), setcchar(), slk_attr_set(), vid_puts(), wattr_get(), wattr_set(), wchgat(), wcolor_set(). + Other functions call these with the corresponding altered behavior, including chgat(), mvchgat(), mvwchgat(), slk_color_on(), slk_color_off(), vid_attr(). + add new functions for manipulating color- and pair-values larger than 16-bits. These are extended_color_content(), extended_pair_content(), extended_slk_color(), init_extended_color(), init_extended_pair(), and the corresponding sp-funcs.
128 lines
4.7 KiB
C
128 lines
4.7 KiB
C
/****************************************************************************
|
|
* Copyright (c) 2017 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 *
|
|
* "Software"), to deal in the Software without restriction, including *
|
|
* without limitation the rights to use, copy, modify, merge, publish, *
|
|
* distribute, distribute with modifications, sublicense, and/or sell *
|
|
* copies of the Software, and to permit persons to whom the Software is *
|
|
* furnished to do so, subject to the following conditions: *
|
|
* *
|
|
* The above copyright notice and this permission notice shall be included *
|
|
* in all copies or substantial portions of the Software. *
|
|
* *
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
|
|
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
|
|
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
|
|
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
|
|
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
|
* *
|
|
* Except as contained in this notice, the name(s) of the above copyright *
|
|
* holders shall not be used in advertising or otherwise to promote the *
|
|
* sale, use or other dealings in this Software without prior written *
|
|
* authorization. *
|
|
****************************************************************************/
|
|
|
|
/****************************************************************************
|
|
* Author: Thomas E. Dickey *
|
|
****************************************************************************/
|
|
|
|
/*
|
|
* Common type definitions and macros for new_pair.c, lib_color.c
|
|
*
|
|
* $Id: new_pair.h,v 1.4 2017/03/31 11:32:07 tom Exp $
|
|
*/
|
|
|
|
#ifndef NEW_PAIR_H
|
|
#define NEW_PAIR_H 1
|
|
/* *INDENT-OFF* */
|
|
|
|
#define USE_NEW_PAIR NCURSES_EXT_COLORS
|
|
|
|
#define MAX_OF_TYPE(t) (int)(((unsigned t)(~0))>>1)
|
|
#define LIMIT_TYPED(n,t) (t)(((t)(n) < 0) ? MAX_OF_TYPE(t) : (n))
|
|
|
|
#define limit_COLOR(n) LIMIT_TYPED(n,NCURSES_COLOR_T)
|
|
#define limit_PAIRS(n) LIMIT_TYPED(n,NCURSES_PAIRS_T)
|
|
|
|
#define MAX_XCURSES_PAIR MAX_OF_TYPE(NCURSES_PAIRS_T)
|
|
|
|
#if USE_NEW_PAIR
|
|
#define OPTIONAL_PAIR GCC_UNUSED
|
|
#define USE_NEW_PAIR NCURSES_EXT_COLORS
|
|
#define get_extended_pair(opts, color_pair) \
|
|
if ((opts) != NULL) { \
|
|
*(int*)(opts) = color_pair; \
|
|
}
|
|
#define set_extended_pair(opts, color_pair) \
|
|
if ((opts) != NULL) { \
|
|
color_pair = *(const int*)(opts); \
|
|
}
|
|
#else
|
|
#define OPTIONAL_PAIR /* nothing */
|
|
#define USE_NEW_PAIR NCURSES_EXT_COLORS
|
|
#define get_extended_pair(opts, color_pair) /* nothing */
|
|
#define set_extended_pair(opts, color_pair) \
|
|
if ((opts) != NULL) { \
|
|
color_pair = -1; \
|
|
}
|
|
#endif
|
|
|
|
#ifdef NEW_PAIR_INTERNAL
|
|
|
|
typedef enum {
|
|
cpKEEP = -1, /* color pair 0 */
|
|
cpFREE = 0, /* free for use */
|
|
cpINIT = 1, /* init_pair() */
|
|
cpAUTO = 1 /* alloc_pair() */
|
|
} CPMODE;
|
|
|
|
typedef struct _color_pairs
|
|
{
|
|
int fg;
|
|
int bg;
|
|
#if USE_NEW_PAIR
|
|
int mode; /* tells if the entry is allocated or free */
|
|
int prev; /* index of previous item */
|
|
int next; /* index of next item */
|
|
#endif
|
|
}
|
|
colorpair_t;
|
|
|
|
#define MakeColorPair(target,f,b) target.fg = f, target.bg = b
|
|
#define isSamePair(a,b) ((a).fg == (b).fg && (a).bg == (b).bg)
|
|
#define FORE_OF(c) (c).fg
|
|
#define BACK_OF(c) (c).bg
|
|
|
|
/*
|
|
* Ensure that we use color pairs only when colors have been started, and also
|
|
* that the index is within the limits of the table which we allocated.
|
|
*/
|
|
#define ValidPair(sp,pair) \
|
|
((sp != 0) && (pair >= 0) && (pair < sp->_pair_limit) && sp->_coloron)
|
|
|
|
#if USE_NEW_PAIR
|
|
extern NCURSES_EXPORT(void) _nc_set_color_pair(SCREEN*, int, int);
|
|
extern NCURSES_EXPORT(void) _nc_reset_color_pair(SCREEN*, int, colorpair_t*);
|
|
#else
|
|
#define _nc_set_color_pair(sp, pair, mode) /* nothing */
|
|
#define _nc_reset_color_pair(sp, pair, data) /* nothing */
|
|
#endif
|
|
|
|
#else
|
|
|
|
typedef struct _color_pairs colorpair_t;
|
|
|
|
#endif /* NEW_PAIR_INTERNAL */
|
|
|
|
#if NO_LEAKS
|
|
extern NCURSES_EXPORT(void) _nc_new_pair_leaks(SCREEN*);
|
|
#endif
|
|
|
|
/* *INDENT-ON* */
|
|
|
|
#endif /* NEW_PAIR_H */
|