void PDC_napms(int ms) { PDC_LOG(("PDC_napms() - called: ms=%d\n", ms)); PDC_update_rects(); SDL_Delay(ms); }
void PDC_gotoyx(int row, int col) { SDL_Rect src, dest; chtype ch; int oldrow, oldcol; PDC_LOG(("PDC_gotoyx() - called: row %d col %d from row %d col %d\n", row, col, SP->cursrow, SP->curscol)); if (SP->mono) return; oldrow = SP->cursrow; oldcol = SP->curscol; /* clear the old cursor */ PDC_transform_line(oldrow, oldcol, 1, curscr->_y[oldrow] + oldcol); if (!SP->visibility) return; /* draw a new cursor by overprinting the existing character in reverse, either the full cell (when visibility == 2) or the lowest quarter of it (when visibility == 1) */ ch = curscr->_y[row][col] ^ A_REVERSE; _set_attr(ch); #ifdef CHTYPE_LONG if (ch & A_ALTCHARSET && !(ch & 0xff80)) ch = acs_map[ch & 0x7f]; #endif src.h = (SP->visibility == 1) ? pdc_fheight >> 2 : pdc_fheight; src.w = pdc_fwidth; dest.y = (row + 1) * pdc_fheight - src.h + pdc_yoffset; dest.x = col * pdc_fwidth + pdc_xoffset; src.x = (ch & 0xff) % 32 * pdc_fwidth; src.y = (ch & 0xff) / 32 * pdc_fheight + (pdc_fheight - src.h); SDL_BlitSurface(pdc_font, &src, pdc_screen, &dest); if (oldrow != row || oldcol != col) { if (rectcount == MAXRECT) PDC_update_rects(); uprect[rectcount++] = dest; } }
bool PDC_check_key(void) { Uint32 current = SDL_GetTicks(); int haveevent = SDL_PollEvent(&event); /* if we have an event, or 30 ms have passed without a screen update, or the timer has wrapped, update now */ if (haveevent || current < pdc_lastupdate || ((current - pdc_lastupdate) > 30)) PDC_update_rects(); return haveevent; }
bool PDC_check_key(void) { Uint32 current = SDL_GetTicks(); int haveevent; /** * SDL_TEXTINPUT can return multiple chars from the IME * which we should handle before polling for additional * events. */ if (event.type == SDL_TEXTINPUT && event.text.text[0]) haveevent = 1; else haveevent = SDL_PollEvent(&event); /* if we have an event, or 30 ms have passed without a screen update, or the timer has wrapped, update now */ if (haveevent || current < pdc_lastupdate || ((current - pdc_lastupdate) > 30)) PDC_update_rects(); return haveevent; }
void PDC_transform_line(int lineno, int x, int len, const chtype *srcp) { SDL_Rect src, dest, lastrect; int j; PDC_LOG(("PDC_transform_line() - called: lineno=%d\n", lineno)); if (rectcount == MAXRECT) PDC_update_rects(); src.h = pdc_fheight; src.w = pdc_fwidth; dest.y = pdc_fheight * lineno + pdc_yoffset; dest.x = pdc_fwidth * x + pdc_xoffset; dest.h = pdc_fheight; dest.w = pdc_fwidth * len; /* if the previous rect was just above this one, with the same width and horizontal position, then merge the new one with it instead of adding a new entry */ if (rectcount) lastrect = uprect[rectcount - 1]; if (rectcount && lastrect.x == dest.x && lastrect.w == dest.w) { if (lastrect.y + lastrect.h == dest.y) uprect[rectcount - 1].h = lastrect.h + pdc_fheight; else if (lastrect.y != dest.y) uprect[rectcount++] = dest; } else uprect[rectcount++] = dest; dest.w = pdc_fwidth; for (j = 0; j < len; j++) { chtype ch = srcp[j]; _set_attr(ch); #ifdef CHTYPE_LONG if (ch & A_ALTCHARSET && !(ch & 0xff80)) ch = (ch & (A_ATTRIBUTES ^ A_ALTCHARSET)) | acs_map[ch & 0x7f]; #endif if (backgr == -1) SDL_LowerBlit(pdc_tileback, &dest, pdc_screen, &dest); src.x = (ch & 0xff) % 32 * pdc_fwidth; src.y = (ch & 0xff) / 32 * pdc_fheight; SDL_LowerBlit(pdc_font, &src, pdc_screen, &dest); if (ch & (A_UNDERLINE|A_LEFTLINE|A_RIGHTLINE)) _highlight(&src, &dest, ch); dest.x += pdc_fwidth; } }