mirror of
https://github.com/VARCem/PDCurses.git
synced 2026-09-24 15:55:14 +00:00
Same for SDL1.
This commit is contained in:
@@ -72,6 +72,7 @@ static SDL_Rect uprect[MAXRECT]; /* table of rects to update */
|
||||
static chtype oldch = (chtype)(-1); /* current attribute */
|
||||
static int rectcount = 0; /* index into uprect */
|
||||
static short foregr = -2, backgr = -2; /* current foreground, background */
|
||||
static bool blinked_off = FALSE;
|
||||
|
||||
/* do the real updates on a delay */
|
||||
|
||||
@@ -359,6 +360,9 @@ void PDC_transform_line(int lineno, int x, int len, const chtype *srcp)
|
||||
|
||||
_set_attr(ch);
|
||||
|
||||
if (blinked_off && (ch & A_BLINK))
|
||||
ch = (ch & A_ATTRIBUTES) | ' ';
|
||||
|
||||
#ifdef CHTYPE_LONG
|
||||
if (ch & A_ALTCHARSET && !(ch & 0xff80))
|
||||
ch = (ch & (A_ATTRIBUTES ^ A_ALTCHARSET)) | acs_map[ch & 0x7f];
|
||||
@@ -397,9 +401,33 @@ void PDC_transform_line(int lineno, int x, int len, const chtype *srcp)
|
||||
SDL_LowerBlit(pdc_font, &src, pdc_screen, &dest);
|
||||
#endif
|
||||
|
||||
if (ch & (A_UNDERLINE|A_LEFTLINE|A_RIGHTLINE))
|
||||
if (!(blinked_off && (ch & A_BLINK)) &&
|
||||
(ch & (A_UNDERLINE|A_LEFTLINE|A_RIGHTLINE)))
|
||||
_highlight(&src, &dest, ch);
|
||||
|
||||
dest.x += pdc_fwidth;
|
||||
}
|
||||
}
|
||||
|
||||
void PDC_blink_text(void)
|
||||
{
|
||||
int i, j, k;
|
||||
|
||||
blinked_off = !blinked_off;
|
||||
|
||||
for (i = 0; i < SP->lines; i++)
|
||||
{
|
||||
const chtype *srcp = curscr->_y[i];
|
||||
|
||||
for (j = 0; j < SP->cols; j++)
|
||||
if (srcp[j] & A_BLINK)
|
||||
{
|
||||
k = j;
|
||||
while (k < SP->cols && (srcp[k] & A_BLINK))
|
||||
k++;
|
||||
PDC_transform_line(i, j, k - j, srcp + j);
|
||||
j = k;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -382,6 +382,8 @@ int PDC_get_key(void)
|
||||
case SDL_KEYDOWN:
|
||||
PDC_mouse_set();
|
||||
return _process_key_event();
|
||||
case SDL_USEREVENT:
|
||||
PDC_blink_text();
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
||||
@@ -29,3 +29,5 @@ extern Uint32 pdc_lastupdate; /* time of last update, in ticks */
|
||||
|
||||
PDCEX void PDC_update_rects(void);
|
||||
PDCEX void PDC_retile(void);
|
||||
|
||||
extern void PDC_blink_text(void);
|
||||
|
||||
@@ -59,13 +59,40 @@ void PDC_set_title(const char *title)
|
||||
SDL_WM_SetCaption(title, 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)
|
||||
{
|
||||
SP->termattrs &= ~A_BLINK;
|
||||
static SDL_TimerID id;
|
||||
|
||||
if (pdc_color_started)
|
||||
COLORS = 256;
|
||||
|
||||
return blinkon ? ERR : OK;
|
||||
if (blinkon)
|
||||
{
|
||||
if (!(SP->termattrs & A_BLINK))
|
||||
{
|
||||
id = SDL_AddTimer(500, _blink_timer, NULL);
|
||||
SP->termattrs |= A_BLINK;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (SP->termattrs & A_BLINK)
|
||||
{
|
||||
SDL_RemoveTimer(id);
|
||||
SP->termattrs &= ~A_BLINK;
|
||||
}
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int PDC_set_bold(bool boldon)
|
||||
|
||||
Reference in New Issue
Block a user