Permalink
Browse files

Changes from Laura Michaels to allow TrueType fonts, and hence wide

builds,  with SDL.  'make -f Makefile WIDE=Y' or 'make -f Makefile.mng
WIDE=Y' will build against SDL_ttf;  otherwise,  the previous 8-bit
characters with bitmapped fonts built against "plain old SDL" are used.

Also,  one can now call resize_term( ) before _initscr( ) or
Xinitscr( ) to set the initial terminal size.  (This already worked
with the X11 and Win32a flavors,  since 2016 Jan 25.)
  • Loading branch information...
Bill-Gray committed Mar 27, 2016
1 parent 28805ac commit 2e7d5ce176aae0dd24ab10e960cbe694d44aeae3
Showing with 222 additions and 11 deletions.
  1. +10 −1 sdl1/Makefile
  2. +13 −2 sdl1/Makefile.mng
  3. +108 −2 sdl1/pdcdisp.c
  4. +82 −4 sdl1/pdcscrn.c
  5. +7 −0 sdl1/pdcsdl.h
  6. +2 −2 sdl1/pdcsetsc.c
View
@@ -19,11 +19,20 @@ SLIBS = $(shell sdl-config --libs)
SFLAGS += -DHAVE_VSNPRINTF -DHAVE_VSSCANF
ifeq ($(DEBUG),Y)
CFLAGS = -g -Wall -DPDCDEBUG
CFLAGS = -g -Wall -DPDCDEBUG -fPIC
else
CFLAGS = -O2 -Wall -fPIC
endif
ifeq ($(WIDE),Y)
CFLAGS += -DPDC_WIDE
SLIBS += -lSDL_ttf
endif
ifeq ($(UTF8),Y)
CFLAGS += -DPDC_FORCE_UTF8
endif
BUILD = $(CC) $(CFLAGS) -I$(PDCURSES_SRCDIR)
ifeq ($(shell uname),Darwin)
View
@@ -12,12 +12,23 @@ osdir = $(PDCURSES_SRCDIR)/sdl1
PDCURSES_SDL_H = $(osdir)/pdcsdl.h
SLIBS = -lSDL
ifeq ($(DEBUG),Y)
CFLAGS = -g -Wall -DPDCDEBUG
else
CFLAGS = -O2 -Wall
endif
ifeq ($(WIDE),Y)
CFLAGS += -DPDC_WIDE
SLIBS += -lSDL_ttf
endif
ifeq ($(UTF8),Y)
CFLAGS += -DPDC_FORCE_UTF8
endif
CC = gcc
BUILD = $(CC) $(CFLAGS) -I$(PDCURSES_SRCDIR)
LDFLAGS = -mwindows $(LIBCURSES)
@@ -34,13 +45,13 @@ ifeq ($(DLL),Y)
LIBFLAGS = -Wl,--out-implib,libpdcurses.a -shared -o
LIBCURSES = pdcurses.dll
CLEAN = $(LIBCURSES) *.a $(DEFFILE)
POST = -lSDL
POST = $(SLIBS)
else
LIBEXE = ar
LIBFLAGS = rcv
LIBCURSES = libpdcurses.a
CLEAN = *.a
LDFLAGS += -lSDL
LDFLAGS += $(SLIBS)
endif
DEMOS += sdltest.exe
View
@@ -17,24 +17,43 @@ chtype acs_map[128] =
A(28), A(29), A(30), A(31), ' ', '!', '"', '#', '$', '%', '&',
'\'', '(', ')', '*',
# ifdef PDC_WIDE
0x2192, 0x2190, 0x2191, 0x2193,
# else
A(0x1a), A(0x1b), A(0x18), A(0x19),
# endif
'/',
# ifdef PDC_WIDE
0x2588,
# else
0xdb,
# endif
'1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=',
'>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
# ifdef PDC_WIDE
0x2666, 0x2592,
# else
A(0x04), 0xb1,
# endif
'b', 'c', 'd', 'e',
# ifdef PDC_WIDE
0x00b0, 0x00b1, 0x2591, 0x00a4, 0x2518, 0x2510, 0x250c, 0x2514,
0x253c, 0x23ba, 0x23bb, 0x2500, 0x23bc, 0x23bd, 0x251c, 0x2524,
0x2534, 0x252c, 0x2502, 0x2264, 0x2265, 0x03c0, 0x2260, 0x00a3,
0x00b7,
# else
0xf8, 0xf1, 0xb0, A(0x0f), 0xd9, 0xbf, 0xda, 0xc0, 0xc5, 0x2d,
0x2d, 0xc4, 0x2d, 0x5f, 0xc3, 0xb4, 0xc1, 0xc2, 0xb3, 0xf3,
0xf2, 0xe3, 0xd8, 0x9c, 0xf9,
# endif
A(127)
};
@@ -100,13 +119,16 @@ static void _set_attr(chtype ch)
if (newfg != foregr)
{
#ifndef PDC_WIDE
SDL_SetPalette(pdc_font, SDL_LOGPAL,
pdc_color + newfg, pdc_flastc, 1);
#endif
foregr = newfg;
}
if (newbg != backgr)
{
#ifndef PDC_WIDE
if (newbg == -1)
SDL_SetColorKey(pdc_font, SDL_SRCCOLORKEY, 0);
else
@@ -117,7 +139,7 @@ static void _set_attr(chtype ch)
SDL_SetPalette(pdc_font, SDL_LOGPAL,
pdc_color + newbg, 0, 1);
}
#endif
backgr = newbg;
}
@@ -132,6 +154,9 @@ void PDC_gotoyx(int row, int col)
SDL_Rect src, dest;
chtype ch;
int oldrow, oldcol;
#ifdef PDC_WIDE
Uint16 chstr[2] = {0, 0};
#endif
PDC_LOG(("PDC_gotoyx() - called: row %d col %d from row %d col %d\n",
row, col, SP->cursrow, SP->curscol));
@@ -167,10 +192,29 @@ void PDC_gotoyx(int row, int col)
dest.y = (row + 1) * pdc_fheight - src.h + pdc_yoffset;
dest.x = col * pdc_fwidth + pdc_xoffset;
#ifdef PDC_WIDE
chstr[0] = ch & A_CHARTEXT;
pdc_font = TTF_RenderUNICODE_Solid(pdc_ttffont, chstr, pdc_color[foregr]);
if (pdc_font)
{
dest.h = src.h;
dest.w = src.w;
src.x = 0;
src.y = 0;
SDL_SetColorKey(pdc_font, 0, 0);
SDL_SetPalette(pdc_font, SDL_LOGPAL, pdc_color + backgr, 0, 1);
SDL_BlitSurface(pdc_font, &src, pdc_screen, &dest);
SDL_FreeSurface(pdc_font);
pdc_font = NULL;
}
#else
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);
#endif
if (oldrow != row || oldcol != col)
{
@@ -186,12 +230,46 @@ void PDC_gotoyx(int row, int col)
static void _highlight(SDL_Rect *src, SDL_Rect *dest, chtype ch)
{
short col = SP->line_color;
#ifdef PDC_WIDE
Uint16 chstr[2] = {'_', 0};
#endif
if (SP->mono)
return;
if (ch & (A_UNDERLINE | A_OVERLINE | A_STRIKEOUT))
{
#ifdef PDC_WIDE
if (col == -1)
col = foregr;
pdc_font = TTF_RenderUNICODE_Solid(pdc_ttffont, chstr, pdc_color[col]);
if (pdc_font)
{
src->x = 0;
src->y = 0;
if (backgr != -1)
SDL_SetColorKey(pdc_font, SDL_SRCCOLORKEY, 0);
if( ch & A_UNDERLINE)
SDL_BlitSurface(pdc_font, src, pdc_screen, dest);
if( ch & A_OVERLINE)
{
dest->y -= pdc_fheight - 1;
SDL_BlitSurface(pdc_font, src, pdc_screen, dest);
dest->y += pdc_fheight - 1;
}
if( ch & A_STRIKEOUT)
{
dest->y -= pdc_fheight / 2;
SDL_BlitSurface(pdc_font, src, pdc_screen, dest);
dest->y += pdc_fheight / 2;
}
SDL_FreeSurface(pdc_font);
pdc_font = NULL;
}
#else
if (col != -1)
SDL_SetPalette(pdc_font, SDL_LOGPAL,
pdc_color + col, pdc_flastc, 1);
@@ -203,7 +281,7 @@ static void _highlight(SDL_Rect *src, SDL_Rect *dest, chtype ch)
SDL_SetColorKey(pdc_font, SDL_SRCCOLORKEY, 0);
if( ch & A_UNDERLINE)
SDL_BlitSurface(pdc_font, src, pdc_screen, dest);
SDL_BlitSurface(pdc_font, src, pdc_screen, dest);
if( ch & A_OVERLINE)
{
dest->y -= pdc_fheight - 1;
@@ -223,6 +301,7 @@ static void _highlight(SDL_Rect *src, SDL_Rect *dest, chtype ch)
if (col != -1)
SDL_SetPalette(pdc_font, SDL_LOGPAL,
pdc_color + foregr, pdc_flastc, 1);
#endif
}
if (ch & (A_LEFTLINE|A_RIGHTLINE))
@@ -253,6 +332,9 @@ void PDC_transform_line(int lineno, int x, int len, const chtype *srcp)
{
SDL_Rect src, dest, lastrect;
int j;
#ifdef PDC_WIDE
Uint16 chstr[2] = {0, 0};
#endif
PDC_LOG(("PDC_transform_line() - called: lineno=%d\n", lineno));
@@ -287,6 +369,11 @@ void PDC_transform_line(int lineno, int x, int len, const chtype *srcp)
dest.w = pdc_fwidth;
#ifdef PDC_WIDE
src.x = 0;
src.y = 0;
#endif
for (j = 0; j < len; j++)
{
chtype ch = srcp[j];
@@ -299,10 +386,29 @@ void PDC_transform_line(int lineno, int x, int len, const chtype *srcp)
if (backgr == -1)
SDL_LowerBlit(pdc_tileback, &dest, pdc_screen, &dest);
#ifdef PDC_WIDE
chstr[0] = ch & A_CHARTEXT;
pdc_font = TTF_RenderUNICODE_Solid(pdc_ttffont, chstr,
pdc_color[foregr]);
if (pdc_font)
{
if (backgr != -1)
{
SDL_SetColorKey(pdc_font, 0, 0);
SDL_SetPalette(pdc_font, SDL_LOGPAL,
pdc_color + backgr, 0, 1);
}
SDL_BlitSurface(pdc_font, &src, pdc_screen, &dest);
SDL_FreeSurface(pdc_font);
pdc_font = NULL;
}
#else
src.x = (ch & 0xff) % 32 * pdc_fwidth;
src.y = (ch & 0xff) / 32 * pdc_fheight;
SDL_LowerBlit(pdc_font, &src, pdc_screen, &dest);
#endif
if (ch & (A_UNDERLINE|A_LEFTLINE|A_RIGHTLINE|A_OVERLINE|A_STRIKEOUT))
_highlight(&src, &dest, ch);
Oops, something went wrong.

0 comments on commit 2e7d5ce

Please sign in to comment.