mirror of
https://github.com/VARCem/PDCurses.git
synced 2026-09-24 15:55:14 +00:00
SDL blink refinement -- as in X11, ensure start on solid, and re-render
after shutdown.
This commit is contained in:
@@ -315,8 +315,8 @@ void PDC_transform_line(int lineno, int x, int len, const chtype *srcp)
|
||||
int j;
|
||||
#ifdef PDC_WIDE
|
||||
Uint16 chstr[2] = {0, 0};
|
||||
attr_t sysattrs = SP->termattrs;
|
||||
#endif
|
||||
attr_t sysattrs = SP->termattrs;
|
||||
|
||||
PDC_LOG(("PDC_transform_line() - called: lineno=%d\n", lineno));
|
||||
|
||||
@@ -362,7 +362,7 @@ void PDC_transform_line(int lineno, int x, int len, const chtype *srcp)
|
||||
|
||||
_set_attr(ch);
|
||||
|
||||
if (blinked_off && (ch & A_BLINK))
|
||||
if (blinked_off && (ch & A_BLINK) && (sysattrs & A_BLINK))
|
||||
ch = (ch & A_ATTRIBUTES) | ' ';
|
||||
|
||||
#ifdef CHTYPE_LONG
|
||||
@@ -403,7 +403,7 @@ void PDC_transform_line(int lineno, int x, int len, const chtype *srcp)
|
||||
SDL_LowerBlit(pdc_font, &src, pdc_screen, &dest);
|
||||
#endif
|
||||
|
||||
if (!(blinked_off && (ch & A_BLINK)) &&
|
||||
if (!(blinked_off && (ch & A_BLINK) && (sysattrs & A_BLINK)) &&
|
||||
(ch & (A_UNDERLINE|A_LEFTLINE|A_RIGHTLINE)))
|
||||
_highlight(&src, &dest, ch);
|
||||
|
||||
@@ -411,10 +411,33 @@ void PDC_transform_line(int lineno, int x, int len, const chtype *srcp)
|
||||
}
|
||||
}
|
||||
|
||||
static Uint32 _blink_timer(Uint32 interval, void *param)
|
||||
{
|
||||
SDL_Event event;
|
||||
|
||||
event.type = SDL_USEREVENT;
|
||||
SDL_PushEvent(&event);
|
||||
return(interval);
|
||||
}
|
||||
|
||||
void PDC_blink_text(void)
|
||||
{
|
||||
static SDL_TimerID blinker_id = 0;
|
||||
int i, j, k;
|
||||
|
||||
oldch = (chtype)(-1);
|
||||
|
||||
if (!(SP->termattrs & A_BLINK))
|
||||
{
|
||||
SDL_RemoveTimer(blinker_id);
|
||||
blinker_id = 0;
|
||||
}
|
||||
else if (!blinker_id)
|
||||
{
|
||||
blinker_id = SDL_AddTimer(500, _blink_timer, NULL);
|
||||
blinked_off = TRUE;
|
||||
}
|
||||
|
||||
blinked_off = !blinked_off;
|
||||
|
||||
for (i = 0; i < SP->lines; i++)
|
||||
@@ -432,4 +455,5 @@ void PDC_blink_text(void)
|
||||
}
|
||||
}
|
||||
|
||||
oldch = (chtype)(-1);
|
||||
}
|
||||
|
||||
@@ -59,19 +59,8 @@ void PDC_set_title(const char *title)
|
||||
SDL_SetWindowTitle(pdc_window, title);
|
||||
}
|
||||
|
||||
static Uint32 _blink_timer(Uint32 interval, void *param)
|
||||
{
|
||||
SDL_Event event;
|
||||
|
||||
event.type = SDL_USEREVENT;
|
||||
SDL_PushEvent(&event);
|
||||
return(interval);
|
||||
}
|
||||
|
||||
int PDC_set_blink(bool blinkon)
|
||||
{
|
||||
static SDL_TimerID id;
|
||||
|
||||
if (pdc_color_started)
|
||||
COLORS = 256;
|
||||
|
||||
@@ -79,16 +68,16 @@ int PDC_set_blink(bool blinkon)
|
||||
{
|
||||
if (!(SP->termattrs & A_BLINK))
|
||||
{
|
||||
id = SDL_AddTimer(500, _blink_timer, NULL);
|
||||
SP->termattrs |= A_BLINK;
|
||||
PDC_blink_text();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (SP->termattrs & A_BLINK)
|
||||
{
|
||||
SDL_RemoveTimer(id);
|
||||
SP->termattrs &= ~A_BLINK;
|
||||
PDC_blink_text();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user