mirror of
https://github.com/VARCem/PDCurses.git
synced 2026-09-25 00:05:16 +00:00
New function, PDC_set_blink(), that toggles blinking on or off, and also
sets COLORS (to 8 if blinking is active, 16 otherwise). Blinking is set to FALSE on startup, if possible. Only implemented for DOS (EGA and VGA) and OS/2; X11 doesn't support blinking, and I can't find a way to change it in Win32 (which so far always is set to intensity mode anyway, for me, though I've heard it might be otherwise -- in 9x?). COLORS is now set to 0 until start_color() is called.
This commit is contained in:
14
curses.h
14
curses.h
@@ -15,7 +15,7 @@
|
||||
* See the file maintain.er for details of the current maintainer. *
|
||||
************************************************************************/
|
||||
|
||||
/* $Id: curses.h,v 1.235 2006/10/11 08:07:58 wmcbrine Exp $ */
|
||||
/* $Id: curses.h,v 1.236 2006/10/12 02:24:18 wmcbrine Exp $ */
|
||||
|
||||
/*----------------------------------------------------------------------*
|
||||
* PDCurses *
|
||||
@@ -43,7 +43,7 @@ PDCurses portable platform definitions list:
|
||||
|
||||
**man-end****************************************************************/
|
||||
|
||||
#define PDC_BUILD 2817
|
||||
#define PDC_BUILD 2818
|
||||
#define PDCURSES 1 /* PDCurses-only routines */
|
||||
#define XOPEN 1 /* X/Open Curses routines */
|
||||
#define SYSVcurses 1 /* System V Curses routines */
|
||||
@@ -575,7 +575,6 @@ typedef struct
|
||||
int sb_cur_x;
|
||||
#endif
|
||||
short line_color; /* Color of line attributes - default white */
|
||||
|
||||
} SCREEN;
|
||||
|
||||
|
||||
@@ -1541,17 +1540,18 @@ int sb_refresh(void);
|
||||
int PDC_chadd(WINDOW *, chtype, bool, bool);
|
||||
int PDC_chins(WINDOW *, chtype, bool);
|
||||
int PDC_ungetch(int);
|
||||
int PDC_set_blink(bool);
|
||||
int PDC_set_line_color(short);
|
||||
void PDC_set_title(const char *);
|
||||
|
||||
int PDC_clearclipboard(void);
|
||||
int PDC_freeclipboard(char *);
|
||||
int PDC_getclipboard(char **, long *);
|
||||
int PDC_setclipboard(const char *, long);
|
||||
int PDC_freeclipboard(char *);
|
||||
int PDC_clearclipboard(void);
|
||||
|
||||
unsigned long PDC_get_input_fd(void);
|
||||
unsigned long PDC_get_key_modifiers(void);
|
||||
|
||||
int PDC_set_line_color(short);
|
||||
|
||||
/*** Functions defined as macros ***/
|
||||
|
||||
/* getch() and ungetch() conflict with some DOS libraries */
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* See the file maintain.er for details of the current maintainer. *
|
||||
************************************************************************/
|
||||
|
||||
/* $Id: curspriv.h,v 1.126 2006/10/11 08:07:58 wmcbrine Exp $ */
|
||||
/* $Id: curspriv.h,v 1.127 2006/10/12 02:24:18 wmcbrine Exp $ */
|
||||
|
||||
/* CURSPRIV.H
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
#define _DLCHAR 0x15 /* Delete Line char (^U) */
|
||||
|
||||
extern bool pdc_trace_on; /* tracing flag */
|
||||
extern bool pdc_color_started;
|
||||
extern WINDOW *pdc_getch_win;
|
||||
extern unsigned long pdc_key_modifiers;
|
||||
extern MOUSE_STATUS pdc_mouse_status;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
#include "pdcdos.h"
|
||||
|
||||
RCSID("$Id: pdcsetsc.c,v 1.29 2006/09/30 15:45:04 wmcbrine Exp $");
|
||||
RCSID("$Id: pdcsetsc.c,v 1.30 2006/10/12 02:24:18 wmcbrine Exp $");
|
||||
|
||||
int PDC_curs_set(int visibility)
|
||||
{
|
||||
@@ -75,3 +75,31 @@ void PDC_set_title(const char *title)
|
||||
{
|
||||
PDC_LOG(("PDC_set_title() - called: <%s>\n", title));
|
||||
}
|
||||
|
||||
int PDC_set_blink(bool blinkon)
|
||||
{
|
||||
PDCREGS regs;
|
||||
|
||||
switch (pdc_adapter)
|
||||
{
|
||||
case _EGACOLOR:
|
||||
case _EGAMONO:
|
||||
case _VGACOLOR:
|
||||
case _VGAMONO:
|
||||
regs.h.ah = 0x10;
|
||||
regs.h.al = 0x03;
|
||||
regs.h.bh = 0;
|
||||
regs.h.bl = blinkon;
|
||||
|
||||
PDCINT(0x10, regs);
|
||||
|
||||
if (pdc_color_started)
|
||||
COLORS = blinkon ? 8 : 16;
|
||||
|
||||
break;
|
||||
default:
|
||||
COLORS = 8;
|
||||
}
|
||||
|
||||
return (COLORS - (blinkon * 8) != 8) ? OK : ERR;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
RCSID("$Id: pdcsetsc.c,v 1.34 2006/10/09 00:12:41 wmcbrine Exp $");
|
||||
RCSID("$Id: pdcsetsc.c,v 1.35 2006/10/12 02:24:19 wmcbrine Exp $");
|
||||
|
||||
int PDC_curs_set(int visibility)
|
||||
{
|
||||
@@ -90,3 +90,27 @@ void PDC_set_title(const char *title)
|
||||
{
|
||||
PDC_LOG(("PDC_set_title() - called:<%s>\n", title));
|
||||
}
|
||||
|
||||
int PDC_set_blink(bool blinkon)
|
||||
{
|
||||
#ifndef EMXVIDEO
|
||||
USHORT statebuf[3], result;
|
||||
|
||||
statebuf[0] = 6; /* length */
|
||||
statebuf[1] = 2; /* blink/intensity */
|
||||
statebuf[2] = !blinkon;
|
||||
|
||||
result = VioSetState(&statebuf, 0);
|
||||
VioGetState(&statebuf, 0); /* needed? */
|
||||
|
||||
if (pdc_color_started)
|
||||
COLORS = statebuf[2] ? 16 : 8;
|
||||
|
||||
return (result == 0) ? OK : ERR;
|
||||
#else
|
||||
if (pdc_color_started)
|
||||
COLORS = 16;
|
||||
|
||||
return blinkon ? ERR : OK;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
RCSID("$Id: color.c,v 1.65 2006/10/11 07:29:10 wmcbrine Exp $");
|
||||
RCSID("$Id: color.c,v 1.66 2006/10/12 02:24:19 wmcbrine Exp $");
|
||||
|
||||
/*man-start**************************************************************
|
||||
|
||||
@@ -92,10 +92,10 @@ RCSID("$Id: color.c,v 1.65 2006/10/11 07:29:10 wmcbrine Exp $");
|
||||
|
||||
**man-end****************************************************************/
|
||||
|
||||
int COLORS = 16;
|
||||
int COLORS = 0;
|
||||
int COLOR_PAIRS = PDC_COLOR_PAIRS;
|
||||
|
||||
static bool color_started = FALSE;
|
||||
bool pdc_color_started = FALSE;
|
||||
|
||||
/* COLOR_PAIR to attribute encoding table. */
|
||||
|
||||
@@ -112,6 +112,10 @@ int start_color(void)
|
||||
if (SP->mono)
|
||||
return ERR;
|
||||
|
||||
pdc_color_started = TRUE;
|
||||
|
||||
PDC_set_blink(FALSE); /* Also sets COLORS, to 8, 16 or 256 */
|
||||
|
||||
if (SP->orig_attr && !getenv("PDC_ORIGINAL_COLORS"))
|
||||
{
|
||||
SP->orig_attr = FALSE;
|
||||
@@ -120,8 +124,6 @@ int start_color(void)
|
||||
|
||||
memset(pair_set, 0, PDC_COLOR_PAIRS);
|
||||
|
||||
color_started = TRUE;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -148,7 +150,7 @@ static void _init_pair_core(short pair, short fg, short bg)
|
||||
if (i & (A_BLINK >> PDC_ATTR_SHIFT))
|
||||
att |= 128;
|
||||
|
||||
pdc_atrtab[(pair * PDC_OFFSET) + i] = att;
|
||||
pdc_atrtab[pair * PDC_OFFSET + i] = att;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,7 +158,7 @@ int init_pair(short pair, short fg, short bg)
|
||||
{
|
||||
PDC_LOG(("init_pair() - called: pair %d fg %d bg %d\n", pair, fg, bg));
|
||||
|
||||
if (!color_started || pair < 1 || pair >= COLOR_PAIRS ||
|
||||
if (!pdc_color_started || pair < 1 || pair >= COLOR_PAIRS ||
|
||||
fg < 0 || fg >= COLORS || bg < 0 || bg >= COLORS)
|
||||
return ERR;
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
#include "pdcwin.h"
|
||||
|
||||
RCSID("$Id: pdcsetsc.c,v 1.30 2006/10/09 14:08:46 wmcbrine Exp $");
|
||||
RCSID("$Id: pdcsetsc.c,v 1.31 2006/10/12 02:24:19 wmcbrine Exp $");
|
||||
|
||||
int PDC_curs_set(int visibility)
|
||||
{
|
||||
@@ -73,3 +73,11 @@ void PDC_set_title(const char *title)
|
||||
SetConsoleTitleA(title);
|
||||
return;
|
||||
}
|
||||
|
||||
int PDC_set_blink(bool blinkon)
|
||||
{
|
||||
if (pdc_color_started)
|
||||
COLORS = 16;
|
||||
|
||||
return blinkon ? ERR : OK;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
RCSID("$Id: pdcsetsc.c,v 1.24 2006/08/21 04:29:46 wmcbrine Exp $");
|
||||
RCSID("$Id: pdcsetsc.c,v 1.25 2006/10/12 02:24:19 wmcbrine Exp $");
|
||||
|
||||
int PDC_curs_set(int visibility)
|
||||
{
|
||||
@@ -69,3 +69,11 @@ void PDC_set_title(const char *title)
|
||||
|
||||
XCursesExitCursesProcess(1, "exiting from PDC_set_title");
|
||||
}
|
||||
|
||||
int PDC_set_blink(bool blinkon)
|
||||
{
|
||||
if (pdc_color_started)
|
||||
COLORS = 16;
|
||||
|
||||
return blinkon ? ERR : OK;
|
||||
}
|
||||
|
||||
15
x11/x11.c
15
x11/x11.c
@@ -32,7 +32,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
RCSID("$Id: x11.c,v 1.24 2006/10/11 07:29:10 wmcbrine Exp $");
|
||||
RCSID("$Id: x11.c,v 1.25 2006/10/12 02:24:19 wmcbrine Exp $");
|
||||
|
||||
#ifndef XPOINTER_TYPEDEFED
|
||||
typedef char * XPointer;
|
||||
@@ -50,9 +50,9 @@ XCursesAppData xc_app_data;
|
||||
# define PDC_SCROLLBAR_TYPE float
|
||||
#endif
|
||||
|
||||
#define MAX_COLORS 8 /* maximum of "normal" colors */
|
||||
#define COLOR_CURSOR 16 /* color of cursor - 1 more than 2 * MAX_COLORS */
|
||||
#define COLOR_BORDER 17 /* color of border - 2 more than 2 * MAX_COLORS */
|
||||
#define MAX_COLORS 16 /* maximum of "normal" colors */
|
||||
#define COLOR_CURSOR MAX_COLORS /* color of cursor */
|
||||
#define COLOR_BORDER MAX_COLORS + 1 /* color of border */
|
||||
|
||||
#define XCURSESDISPLAY (XtDisplay(drawing))
|
||||
#define XCURSESWIN (XtWindow(drawing))
|
||||
@@ -606,7 +606,7 @@ static XtActionsRec Actions[] =
|
||||
};
|
||||
|
||||
static Bool after_first_curses_request = False;
|
||||
static Pixel colors[(2 * MAX_COLORS) + 2];
|
||||
static Pixel colors[MAX_COLORS + 2];
|
||||
static Bool vertical_cursor = False;
|
||||
|
||||
#ifdef FOREIGN
|
||||
@@ -908,6 +908,7 @@ static void get_colors(void)
|
||||
colors[13] = xc_app_data.colorBoldMagenta;
|
||||
colors[14] = xc_app_data.colorBoldCyan;
|
||||
colors[15] = xc_app_data.colorBoldWhite;
|
||||
|
||||
colors[COLOR_CURSOR] = xc_app_data.cursorColor;
|
||||
colors[COLOR_BORDER] = xc_app_data.borderColor;
|
||||
}
|
||||
@@ -943,8 +944,8 @@ static void SetCursorColor(chtype *ch, short *fore, short *back)
|
||||
if (attr)
|
||||
{
|
||||
pair_content(attr, &f, &b);
|
||||
*fore = 7 - f;
|
||||
*back = 7 - b;
|
||||
*fore = 7 - (f % 8);
|
||||
*back = 7 - (b % 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user