mirror of
https://github.com/VARCem/PDCurses.git
synced 2026-09-25 08:15:27 +00:00
Underlining for SDL; do SDL_MapRGB() only at color init time. Left/right
highlighting and line_color not implemented yet.
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
RCSID("$Id: pdcdisp.c,v 1.5 2007/06/12 10:29:58 wmcbrine Exp $");
|
||||
RCSID("$Id: pdcdisp.c,v 1.6 2007/06/13 19:53:36 wmcbrine Exp $");
|
||||
|
||||
#ifdef CHTYPE_LONG
|
||||
|
||||
@@ -61,7 +61,6 @@ chtype acs_map[128] =
|
||||
void PDC_gotoyx(int row, int col)
|
||||
{
|
||||
SDL_Rect dest;
|
||||
Uint32 curcol;
|
||||
chtype ch;
|
||||
short fg, bg;
|
||||
|
||||
@@ -80,9 +79,6 @@ void PDC_gotoyx(int row, int col)
|
||||
if (ch & A_REVERSE)
|
||||
fg = bg;
|
||||
|
||||
curcol = SDL_MapRGB(pdc_screen->format, pdc_color[fg].r,
|
||||
pdc_color[fg].g, pdc_color[fg].b);
|
||||
|
||||
dest.h = (SP->visibility == 1) ? pdc_fheight >> 2 : pdc_fheight;
|
||||
|
||||
dest.y = (row + 1) * pdc_fheight - dest.h;
|
||||
@@ -90,7 +86,7 @@ void PDC_gotoyx(int row, int col)
|
||||
|
||||
dest.w = pdc_fwidth;
|
||||
|
||||
SDL_FillRect(pdc_screen, &dest, curcol);
|
||||
SDL_FillRect(pdc_screen, &dest, pdc_mapped[fg]);
|
||||
SDL_UpdateRect(pdc_screen, dest.x, dest.y, dest.w, dest.h);
|
||||
}
|
||||
|
||||
@@ -141,10 +137,10 @@ void PDC_transform_line(int lineno, int x, int len, const chtype *srcp)
|
||||
{
|
||||
chtype ch = srcp[j];
|
||||
|
||||
if (!j || ((ch & A_ATTRIBUTES) != oldch))
|
||||
if (!j || ((ch & (A_ATTRIBUTES ^ A_ALTCHARSET)) != oldch))
|
||||
{
|
||||
_set_attr(ch);
|
||||
oldch = ch & A_ATTRIBUTES;
|
||||
oldch = ch & (A_ATTRIBUTES ^ A_ALTCHARSET);
|
||||
}
|
||||
|
||||
#ifdef CHTYPE_LONG
|
||||
@@ -156,6 +152,17 @@ void PDC_transform_line(int lineno, int x, int len, const chtype *srcp)
|
||||
src.y = (ch & 0xff) / 32 * pdc_fheight;
|
||||
|
||||
SDL_BlitSurface(pdc_font, &src, pdc_screen, &dest);
|
||||
|
||||
if (oldch & A_UNDERLINE)
|
||||
{
|
||||
SDL_SetColorKey(pdc_font, SDL_SRCCOLORKEY, 1);
|
||||
|
||||
src.x = '_' % 32 * pdc_fwidth;
|
||||
src.y = '_' / 32 * pdc_fheight;
|
||||
|
||||
SDL_BlitSurface(pdc_font, &src, pdc_screen, &dest);
|
||||
SDL_SetColorKey(pdc_font, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
SDL_UpdateRect(pdc_screen, x * pdc_fwidth, lineno * pdc_fheight,
|
||||
|
||||
@@ -15,10 +15,11 @@
|
||||
#include "deffont.h"
|
||||
#include "deficon.h"
|
||||
|
||||
RCSID("$Id: pdcscrn.c,v 1.7 2007/06/13 18:34:40 wmcbrine Exp $");
|
||||
RCSID("$Id: pdcscrn.c,v 1.8 2007/06/13 19:53:36 wmcbrine Exp $");
|
||||
|
||||
SDL_Surface *pdc_screen = NULL, *pdc_font = NULL, *pdc_icon = NULL;
|
||||
SDL_Color pdc_color[16];
|
||||
Uint32 pdc_mapped[16];
|
||||
int pdc_fheight, pdc_fwidth, pdc_sheight, pdc_swidth;
|
||||
|
||||
static bool own_screen;
|
||||
@@ -122,6 +123,10 @@ int PDC_scr_open(int argc, char **argv)
|
||||
pdc_color[i + 8].b = (i & COLOR_BLUE) ? 0xff : 0x40;
|
||||
}
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
pdc_mapped[i] = SDL_MapRGB(pdc_screen->format,
|
||||
pdc_color[i].r, pdc_color[i].g, pdc_color[i].b);
|
||||
|
||||
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,
|
||||
SDL_DEFAULT_REPEAT_INTERVAL);
|
||||
SDL_EnableUNICODE(1);
|
||||
@@ -200,6 +205,9 @@ int PDC_init_color(short color, short red, short green, short blue)
|
||||
pdc_color[color].g = DIVROUND(green * 255, 1000);
|
||||
pdc_color[color].b = DIVROUND(blue * 255, 1000);
|
||||
|
||||
pdc_mapped[color] = SDL_MapRGB(pdc_screen->format,
|
||||
pdc_color[color].r, pdc_color[color].g, pdc_color[color].b);
|
||||
|
||||
wrefresh(curscr);
|
||||
|
||||
return OK;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* See the file maintain.er for details of the current maintainer. *
|
||||
************************************************************************/
|
||||
|
||||
/* $Id: pdcsdl.h,v 1.2 2007/06/13 17:43:31 wmcbrine Exp $ */
|
||||
/* $Id: pdcsdl.h,v 1.3 2007/06/13 19:53:36 wmcbrine Exp $ */
|
||||
|
||||
#include <curspriv.h>
|
||||
|
||||
@@ -19,4 +19,5 @@
|
||||
|
||||
extern SDL_Surface *pdc_screen, *pdc_font;
|
||||
extern SDL_Color pdc_color[16];
|
||||
extern Uint32 pdc_mapped[16];
|
||||
extern int pdc_fheight, pdc_fwidth, pdc_sheight, pdc_swidth;
|
||||
|
||||
Reference in New Issue
Block a user