diff --git a/doc/sdl2.txt b/doc/sdl2.txt index 7375ff0e..8048cb75 100644 --- a/doc/sdl2.txt +++ b/doc/sdl2.txt @@ -4,46 +4,46 @@ SDL2 Considerations Clipboard --------- -SDL2 port uses functionality provided by the SDL2 clipboard functions to add +SDL2 port uses functionality provided by the SDL2 clipboard functions to add basic clipboard support. Fonts ----- -If the PDC_WIDE flag is set, SDL2 version uses SDL2_ttf and SDL version -uses SDL_ttf to render fonts. This allows for use of a full UCS-2 (16 bit +If the PDC_WIDE flag is set, SDL2 version uses SDL2_ttf and SDL version +uses SDL_ttf to render fonts. This allows for use of a full UCS-2 (16 bit Unicode) character set. -SDL2 has several changes from SDL on how to handle Unicode character input -including the addition of SDL_TEXTINPUT event and new functions to use with it. -This allows use of an input method editor to enter characters that may not be -standard for the keyboard. For simplicity, the pdcurses SDL_ttf additions -don't use this new added functionality. They take an approach that will work -with SDL or SDL2. Windows users may be familiar with holding down the alt key -while entering a numeric value via the keypad. Windows translates this input -and the number into a character. The SDL ports with PDC_WIDE option use a -similar technique across all platforms not just Windows. +SDL2 has several changes from SDL on how to handle Unicode character input +including the addition of SDL_TEXTINPUT event and new functions to use with it. +This allows use of an input method editor to enter characters that may not be +standard for the keyboard. For simplicity, the pdcurses SDL_ttf additions +don't use this new added functionality. They take an approach that will work +with SDL or SDL2. Windows users may be familiar with holding down the alt key +while entering a numeric value via the keypad. Windows translates this input +and the number into a character. The SDL ports with PDC_WIDE option use a +similar technique across all platforms not just Windows. -To enter a hexidecimal value for a character, hold down the alt key and press -plus on the numeric keypad. Then, enter the hexidecimal code for the -character. Then, release the alt key. To enter a decimal number, hold down -the alt key and press 0 on the keypad, followed by the decimal equivalent of +To enter a hexidecimal value for a character, hold down the alt key and press +plus on the numeric keypad. Then, enter the hexidecimal code for the +character. Then, release the alt key. To enter a decimal number, hold down +the alt key and press 0 on the keypad, followed by the decimal equivalent of the character. Release the alt key. This allows users to enter characters not -available on their keyboards without need for additional code or programs to +available on their keyboards without need for additional code or programs to deal with input. The default Truetype font used is a monospaced font. One can specify another -font using the integration methods described. The font does not necessarily -need to be a monospaced font. Since PDCurses assumes a fixed size (default -screen size is 80x25), a monospaced font may look better on screen than other +font using the integration methods described. The font does not necessarily +need to be a monospaced font. Since PDCurses assumes a fixed size (default +screen size is 80x25), a monospaced font may look better on screen than other types of fonts. Integration with SDL2 and SDL2_TTF or SDL_TTF --------------------------------------------- -As mentioned in SDL Considerations document, the SDL port uses the following +As mentioned in SDL Considerations document, the SDL port uses the following variables: PDCEX SDL_Surface *pdc_screen, *pdc_font, *pdc_icon, *pdc_back; @@ -54,47 +54,47 @@ The SDL2 port adds: SDL_Window *pdc_window; SDL_Renderer *pdc_render; SDL_Texture *pdc_texture; - -Using SDL_ttf (with SDL2 or SDL) adds: + +Using SDL_ttf (with SDL2 or SDL) adds: TTF_Font *pdc_ttffont; SDL_Color *pdc_ttffont_foregroundcolor; SDL_Color *pdc_ttffont_backgroundcolor; int pdc_ttffont_spointsz; int pdc_ttffont_hint; - + These can be used or modified in your own code. Like the pdc_screen variable -used by the SDL port, you can initialize pdc_window, pdc_render, +used by the SDL port, you can initialize pdc_window, pdc_render, pdc_texture in your own code. If it's not initialized, PDCurses will do it for you. See the sdltest demo for an example. If PDCurses is built with -the PDC_WIDE flag, it will clean up/deallocate these variables on exit when +the PDC_WIDE flag, it will clean up/deallocate these variables on exit when needed. -Default font for SDL_TTF is assumed to be DejaVuSansMono.ttf from the Open +Default font for SDL_TTF is assumed to be DejaVuSansMono.ttf from the Open Source DejaVu fonts. The code looks for this font to already be installed in -a standard directory (based on the Filesystem Hierarchy Standard) -/usr/local/share/fonts/truetype/dejavu/. This can be modified by setting a -define during compile time -( -DPDC_FONT_PATH=/usr/share/fonts/truetype/dejavu/ ) This can be overridden -by initializing pdc_ttffont in your own code. Similar to the -PDC_FONT environment variable for SDL bitmap fonts, one can also override TTF +a standard directory (based on the Filesystem Hierarchy Standard) +/usr/local/share/fonts/truetype/dejavu/. This can be modified by setting a +define during compile time +( -DPDC_FONT_PATH=/usr/share/fonts/truetype/dejavu/ ) This can be overridden +by initializing pdc_ttffont in your own code. Similar to the +PDC_FONT environment variable for SDL bitmap fonts, one can also override TTF fonts using the PDC_FONT and PDC_FONT_POINT_SIZE environment variables. -How a font is rendered on the screen depends on a number of factors. -TTF_SetFontHinting (from SDL_TTF or SDL2_TTF) uses the pdc_ttffont_hint setting -which can affect how the font appears on the screen. Default for PDCurses is -currently TTF_HINTING_MONO, but one can also use TTF_HINTING_NORMAL, -TTF_HINTING_LIGHT, TTF_HINTING_NONE by setting pdc_ttffont_hint before -PDCurses initializes pdc_ttffont. If you initialize pdc_ttffont in your own -code, TTF_SetFontHinting is not called by PDCurses and the default setting is +How a font is rendered on the screen depends on a number of factors. +TTF_SetFontHinting (from SDL_TTF or SDL2_TTF) uses the pdc_ttffont_hint setting +which can affect how the font appears on the screen. Default for PDCurses is +currently TTF_HINTING_MONO, but one can also use TTF_HINTING_NORMAL, +TTF_HINTING_LIGHT, TTF_HINTING_NONE by setting pdc_ttffont_hint before +PDCurses initializes pdc_ttffont. If you initialize pdc_ttffont in your own +code, TTF_SetFontHinting is not called by PDCurses and the default setting is TTF_HINTING_NORMAL. This can always be changed in your own code by calling -TTF_SetFontHinting. The font is also affected by the settings used when -building the freetype library (which SDL_TTF or SDL2_TTF uses). For example, -on Windows, one may want to add the following compile time flags when building +TTF_SetFontHinting. The font is also affected by the settings used when +building the freetype library (which SDL_TTF or SDL2_TTF uses). For example, +on Windows, one may want to add the following compile time flags when building the freetype library: -DTT_CONFIG_OPTION_SUBPIXEL_HINTING -DFT_CONFIG_OPTION_SUBPIXEL_RENDERING -Some testing was done building freetype with and without harfbuzz library and -that did not seem to affect TTF rendering. (Harfbuzz mainly relates to +Some testing was done building freetype with and without harfbuzz library and +that did not seem to affect TTF rendering. (Harfbuzz mainly relates to OpenType fonts, OTF rendering.) diff --git a/sdl2/Makefile b/sdl2/Makefile index 0bf4ab0e..f8e97d7d 100644 --- a/sdl2/Makefile +++ b/sdl2/Makefile @@ -19,7 +19,7 @@ osdir = $(PDCURSES_SRCDIR)/sdl2 PDCURSES_SDL_H = $(osdir)/pdcsdl.h -SFLAGS = $(shell pkg-config --cflags sdl2_ttf sdl2) +SFLAGS = $(shell pkg-config --cflags sdl2_ttf sdl2) SLIBS = $(shell pkg-config --libs sdl2_ttf sdl2) # If your system doesn't have these, remove the defines here @@ -29,7 +29,7 @@ ifeq ($(DEBUG),Y) CFLAGS = -g -Wall -DPDCDEBUG else CFLAGS:= $(CFLAGS) - CFLAGS += -O2 -Wall + CFLAGS += -O2 -Wall LDFLAGS:= $(LDFLAGS) endif diff --git a/sdl2/Makefile.mng b/sdl2/Makefile.mng index 427edc67..80f80e21 100644 --- a/sdl2/Makefile.mng +++ b/sdl2/Makefile.mng @@ -60,9 +60,9 @@ demos: $(DEMOS) pdcurses.dll: $(DEFFILE) $(DEFFILE): $(DEFDEPS) - echo LIBRARY pdcurses > $@ - echo EXPORTS >> $@ - type $(BASEDEF) >> $@ + echo LIBRARY pdcurses > $@ + echo EXPORTS >> $@ + type $(BASEDEF) >> $@ echo pdc_screen >> $@ echo pdc_font >> $@ echo pdc_icon >> $@ diff --git a/sdl2/README b/sdl2/README index 35234d39..213d23f6 100644 --- a/sdl2/README +++ b/sdl2/README @@ -9,7 +9,7 @@ Building . On *nix (including Linux and Mac OS X), run "make" in the sdl1 directory. There is no configure script (yet?) for this port. This - assumes a working sdl-config, and GNU make. It builds the library + assumes a working sdl-config, and GNU make. It builds the library libpdcurses.a (dynamic lib not implemented). With MinGW, run "make -f Makefile.mng". This assumes SDL is installed @@ -17,7 +17,7 @@ Building parameters "DLL=Y" and "DEBUG=Y", as with the console version. (Wide- character support is not yet implemented for SDL.) Both makefiles recognize the optional PDCURSES_SRCDIR environment variable, as with - the console ports. Makefile.mng builds libpdcurses.a, along with + the console ports. Makefile.mng builds libpdcurses.a, along with pdcurses.dll, if specified. diff --git a/sdl2/pdcclip.c b/sdl2/pdcclip.c index 6f7d4a38..b6f216e7 100644 --- a/sdl2/pdcclip.c +++ b/sdl2/pdcclip.c @@ -17,14 +17,14 @@ RCSID("$Id: pdcclip.c,v 1.6 2008/07/14 04:24:52 wmcbrine Exp $") int PDC_clearclipboard(void); Description: - PDC_getclipboard() gets the textual contents of the system's - clipboard. This function returns the contents of the clipboard - in the contents argument. It is the responsibilitiy of the + PDC_getclipboard() gets the textual contents of the system's + clipboard. This function returns the contents of the clipboard + in the contents argument. It is the responsibilitiy of the caller to free the memory returned, via PDC_freeclipboard(). - The length of the clipboard contents is returned in the length + The length of the clipboard contents is returned in the length argument. - PDC_setclipboard copies the supplied text into the system's + PDC_setclipboard copies the supplied text into the system's clipboard, emptying the clipboard prior to the copy. PDC_clearclipboard() clears the internal clipboard. @@ -32,7 +32,7 @@ RCSID("$Id: pdcclip.c,v 1.6 2008/07/14 04:24:52 wmcbrine Exp $") Return Values: indicator of success/failure of call. PDC_CLIP_SUCCESS the call was successful - PDC_CLIP_MEMORY_ERROR unable to allocate sufficient memory for + PDC_CLIP_MEMORY_ERROR unable to allocate sufficient memory for the clipboard contents PDC_CLIP_EMPTY the clipboard contains no text PDC_CLIP_ACCESS_ERROR no clipboard support @@ -51,10 +51,10 @@ int PDC_getclipboard(char **contents, long *length) { PDC_LOG(("PDC_getclipboard() - called\n")); - if (SDL_HasClipboardText() == SDL_FALSE) - return PDC_CLIP_EMPTY; - *contents = SDL_GetClipboardText(); - *length = strlen (*contents); + if (SDL_HasClipboardText() == SDL_FALSE) + return PDC_CLIP_EMPTY; + *contents = SDL_GetClipboardText(); + *length = strlen(*contents); return PDC_CLIP_SUCCESS; } @@ -82,10 +82,10 @@ int PDC_clearclipboard(void) { PDC_LOG(("PDC_clearclipboard() - called\n")); - if (SDL_HasClipboardText() == SDL_TRUE) - { - SDL_SetClipboardText(NULL); - } + if (SDL_HasClipboardText() == SDL_TRUE) + { + SDL_SetClipboardText(NULL); + } return PDC_CLIP_SUCCESS; } diff --git a/sdl2/pdcdisp.c b/sdl2/pdcdisp.c index 258bc31b..5b8f8cd1 100644 --- a/sdl2/pdcdisp.c +++ b/sdl2/pdcdisp.c @@ -15,8 +15,8 @@ chtype acs_map[128] = { A(0), A(1), A(2), A(3), A(4), A(5), A(6), A(7), A(8), A(9), A(10), A(11), A(12), A(13), A(14), A(15), A(16), A(17), A(18), A(19), - A(20), A(21), A(22), A(23), A(24), A(25), A(26), A(27), A(28), - A(29), A(30), A(31), ' ', '!', '"', '#', '$', '%', '&', '\'', '(', + A(20), A(21), A(22), A(23), A(24), A(25), A(26), A(27), A(28), + A(29), A(30), A(31), ' ', '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', # ifdef PDC_WIDE @@ -81,7 +81,7 @@ void PDC_update_rects(void) { if (rectcount) { - /* if the maximum number of rects has been reached, we're + /* if the maximum number of rects has been reached, we're probably better off doing a full screen update */ if (rectcount == MAXRECT) @@ -97,7 +97,7 @@ void PDC_update_rects(void) SDL_RenderClear(pdc_render); SDL_RenderCopy(pdc_render, pdc_texture, NULL, NULL); SDL_RenderPresent(pdc_render); - } + } pdc_lastupdate = SDL_GetTicks(); rectcount = 0; @@ -150,7 +150,7 @@ static void _set_attr(chtype ch) oldch = ch; } -#else +#else ch &= (A_COLOR|A_BOLD|A_BLINK|A_REVERSE); if (oldch != ch) @@ -174,7 +174,7 @@ static void _set_attr(chtype ch) if (newfg != foregr) { - SDL_SetPalette(pdc_font, SDL_LOGPAL, + SDL_SetPalette(pdc_font, SDL_LOGPAL, pdc_color + newfg, pdc_flastc, 1); foregr = newfg; } @@ -197,7 +197,7 @@ static void _set_attr(chtype ch) oldch = ch; } -#endif +#endif } /* draw a cursor at (y, x) */ @@ -211,7 +211,7 @@ void PDC_gotoyx(int row, int col) Uint16 chstr[2] = {0, 0}; Uint32 colorkey; #endif - + PDC_LOG(("PDC_gotoyx() - called: row %d col %d from row %d col %d\n", row, col, SP->cursrow, SP->curscol)); @@ -229,8 +229,8 @@ void PDC_gotoyx(int row, int col) if (!SP->visibility) return; - /* draw a new cursor by overprinting the existing character in - reverse, either the full cell (when visibility == 2) or the + /* 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; @@ -243,31 +243,31 @@ void PDC_gotoyx(int row, int col) #endif #ifdef PDC_WIDE chstr[0] = ch & A_CHARTEXT; - - pdc_font = TTF_RenderUNICODE_Solid (pdc_ttffont,chstr,*pdc_ttffont_foregroundcolor); + + pdc_font = TTF_RenderUNICODE_Solid(pdc_ttffont,chstr,*pdc_ttffont_foregroundcolor); if (pdc_font) - { + { colorkey = SDL_MapRGB(pdc_screen->format, pdc_ttffont_backgroundcolor->r,pdc_ttffont_backgroundcolor->g, pdc_ttffont_backgroundcolor->b); src.h = (SP->visibility == 1) ? pdc_fheight >> 2 : pdc_fheight; if (src.h > pdc_font->h) - src.h = pdc_font->h; + src.h = pdc_font->h; src.w = pdc_fwidth; if (src.w > pdc_font->w) - src.w = pdc_font->w; + src.w = pdc_font->w; dest.y = (row + 1) * pdc_fheight - src.h + pdc_yoffset; dest.x = col * pdc_fwidth + pdc_xoffset; dest.h = (SP->visibility == 1) ? pdc_fheight >> 2 : pdc_fheight; dest.w = pdc_fwidth; - SDL_FillRect (pdc_screen, &dest, colorkey); + SDL_FillRect(pdc_screen, &dest, colorkey); dest.h = pdc_fheight; src.x = 0; src.y = 0; colorkey = SDL_MapRGB(pdc_screen->format, 0,0,0); - SDL_BlitSurface(pdc_font, &src, pdc_screen, &dest); + SDL_BlitSurface(pdc_font, &src, pdc_screen, &dest); SDL_FreeSurface(pdc_font); pdc_font = NULL; - } -#else + } +#else src.h = (SP->visibility == 1) ? pdc_fheight >> 2 : pdc_fheight; src.w = pdc_fwidth; @@ -278,7 +278,7 @@ void PDC_gotoyx(int row, int col) src.y = (ch & 0xff) / 32 * pdc_fheight + (pdc_fheight - src.h); SDL_BlitSurface(pdc_font, &src, pdc_screen, &dest); -#endif +#endif if (oldrow != row || oldcol != col) { @@ -304,23 +304,23 @@ static void _highlight(SDL_Rect *src, SDL_Rect *dest, chtype ch) if (ch & A_UNDERLINE) { #ifdef PDC_WIDE - pdc_font = TTF_RenderText_Solid (pdc_ttffont,chstr,*pdc_ttffont_foregroundcolor); + pdc_font = TTF_RenderText_Solid(pdc_ttffont,chstr,*pdc_ttffont_foregroundcolor); if (pdc_font) - { - src->x = 0; - src->y = 0; - - if (backgr != -1) - SDL_SetColorKey(pdc_font, SDL_TRUE, 0); - - SDL_BlitSurface(pdc_font, src, pdc_screen, dest); - + { + src->x = 0; + src->y = 0; + + if (backgr != -1) + SDL_SetColorKey(pdc_font, SDL_TRUE, 0); + + SDL_BlitSurface(pdc_font, src, pdc_screen, dest); + if (backgr != -1) SDL_SetColorKey(pdc_font, 0, 0); SDL_FreeSurface(pdc_font); pdc_font = NULL; - } -#else + } +#else if (col != -1) SDL_SetPalette(pdc_font, SDL_LOGPAL, pdc_color + col, pdc_flastc, 1); @@ -339,7 +339,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 +#endif } if (ch & (A_LEFTLINE|A_RIGHTLINE)) @@ -402,7 +402,7 @@ void PDC_transform_line(int lineno, int x, int len, const chtype *srcp) else if (lastrect.y != dest.y) uprect[rectcount++] = dest; - } + } else uprect[rectcount++] = dest; @@ -422,28 +422,28 @@ void PDC_transform_line(int lineno, int x, int len, const chtype *srcp) #ifdef PDC_WIDE chstr[0] = ch & A_CHARTEXT; - pdc_font = TTF_RenderUNICODE_Solid (pdc_ttffont,chstr,*pdc_ttffont_foregroundcolor); + pdc_font = TTF_RenderUNICODE_Solid(pdc_ttffont,chstr,*pdc_ttffont_foregroundcolor); if (pdc_font) - { - colorkey = SDL_MapRGB(pdc_screen->format, pdc_ttffont_backgroundcolor->r,pdc_ttffont_backgroundcolor->g, pdc_ttffont_backgroundcolor->b); - dest.w = pdc_fwidth; - dest.h = pdc_fheight; - SDL_FillRect (pdc_screen, &dest, colorkey); - src.x = 0; - src.y = 0; - src.h = pdc_font->h; - src.w = pdc_font->w; - colorkey = SDL_MapRGB(pdc_screen->format, 0,0,0); - SDL_BlitSurface(pdc_font, &src, pdc_screen, &dest); - SDL_FreeSurface(pdc_font); - pdc_font = NULL; - } -#else + { + colorkey = SDL_MapRGB(pdc_screen->format, pdc_ttffont_backgroundcolor->r,pdc_ttffont_backgroundcolor->g, pdc_ttffont_backgroundcolor->b); + dest.w = pdc_fwidth; + dest.h = pdc_fheight; + SDL_FillRect(pdc_screen, &dest, colorkey); + src.x = 0; + src.y = 0; + src.h = pdc_font->h; + src.w = pdc_font->w; + colorkey = SDL_MapRGB(pdc_screen->format, 0,0,0); + 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 +#endif if (ch & (A_UNDERLINE|A_LEFTLINE|A_RIGHTLINE)) _highlight(&src, &dest, ch); diff --git a/sdl2/pdckbd.c b/sdl2/pdckbd.c index 0593de2e..dc104cb4 100644 --- a/sdl2/pdckbd.c +++ b/sdl2/pdckbd.c @@ -12,7 +12,7 @@ RCSID("$Id: pdckbd.c,v 1.20 2008/07/14 04:24:52 wmcbrine Exp $") unsigned long PDC_get_input_fd(void); Description: - PDC_get_input_fd() returns the file descriptor that PDCurses + PDC_get_input_fd() returns the file descriptor that PDCurses reads its input from. It can be used for select(). Portability X/Open BSD SYS V @@ -38,58 +38,58 @@ static struct unsigned short alt; } key_table[] = { -/* keycode keypad normal shifted control alt*/ - {SDLK_LEFT, FALSE, KEY_LEFT, KEY_SLEFT, CTL_LEFT, ALT_LEFT}, - {SDLK_RIGHT, FALSE, KEY_RIGHT, KEY_SRIGHT, CTL_RIGHT, ALT_RIGHT}, - {SDLK_UP, FALSE, KEY_UP, KEY_SUP, CTL_UP, ALT_UP}, - {SDLK_DOWN, FALSE, KEY_DOWN, KEY_SDOWN, CTL_DOWN, ALT_DOWN}, - {SDLK_HOME, FALSE, KEY_HOME, KEY_SHOME, CTL_HOME, ALT_HOME}, - {SDLK_END, FALSE, KEY_END, KEY_SEND, CTL_END, ALT_END}, - {SDLK_PAGEUP, FALSE, KEY_PPAGE, KEY_SPREVIOUS,CTL_PGUP, ALT_PGUP}, - {SDLK_PAGEDOWN,FALSE, KEY_NPAGE, KEY_SNEXT, CTL_PGDN, ALT_PGDN}, - {SDLK_INSERT, FALSE, KEY_IC, KEY_SIC, CTL_INS, ALT_INS}, - {SDLK_DELETE, FALSE, KEY_DC, KEY_SDC, CTL_DEL, ALT_DEL}, - {SDLK_F1, FALSE, KEY_F(1), KEY_F(13), KEY_F(25), KEY_F(37)}, - {SDLK_F2, FALSE, KEY_F(2), KEY_F(14), KEY_F(26), KEY_F(38)}, - {SDLK_F3, FALSE, KEY_F(3), KEY_F(15), KEY_F(27), KEY_F(39)}, - {SDLK_F4, FALSE, KEY_F(4), KEY_F(16), KEY_F(28), KEY_F(40)}, - {SDLK_F5, FALSE, KEY_F(5), KEY_F(17), KEY_F(29), KEY_F(41)}, - {SDLK_F6, FALSE, KEY_F(6), KEY_F(18), KEY_F(30), KEY_F(42)}, - {SDLK_F7, FALSE, KEY_F(7), KEY_F(19), KEY_F(31), KEY_F(43)}, - {SDLK_F8, FALSE, KEY_F(8), KEY_F(20), KEY_F(32), KEY_F(44)}, - {SDLK_F9, FALSE, KEY_F(9), KEY_F(21), KEY_F(33), KEY_F(45)}, - {SDLK_F10, FALSE, KEY_F(10), KEY_F(22), KEY_F(34), KEY_F(46)}, - {SDLK_F11, FALSE, KEY_F(11), KEY_F(23), KEY_F(35), KEY_F(47)}, - {SDLK_F12, FALSE, KEY_F(12), KEY_F(24), KEY_F(36), KEY_F(48)}, - {SDLK_F13, FALSE, KEY_F(13), KEY_F(25), KEY_F(37), KEY_F(49)}, - {SDLK_F14, FALSE, KEY_F(14), KEY_F(26), KEY_F(38), KEY_F(50)}, - {SDLK_F15, FALSE, KEY_F(15), KEY_F(27), KEY_F(39), KEY_F(51)}, - {SDLK_BACKSPACE,FALSE, 0x08, 0x08, CTL_BKSP, ALT_BKSP}, - {SDLK_TAB, FALSE, 0x09, KEY_BTAB, CTL_TAB, ALT_TAB}, - {SDLK_PRINTSCREEN, FALSE, KEY_PRINT, KEY_SPRINT, KEY_PRINT, KEY_PRINT}, - {SDLK_PAUSE, FALSE, KEY_SUSPEND, KEY_SSUSPEND, KEY_SUSPEND, KEY_SUSPEND}, - {SDLK_CLEAR, FALSE, KEY_CLEAR, KEY_CLEAR, KEY_CLEAR, KEY_CLEAR}, - {SDLK_PAUSE, FALSE, KEY_BREAK, KEY_BREAK, KEY_BREAK, KEY_BREAK}, - {SDLK_HELP, FALSE, KEY_HELP, KEY_SHELP, KEY_LHELP, KEY_HELP}, - {SDLK_MENU, FALSE, KEY_OPTIONS, KEY_SOPTIONS, KEY_OPTIONS, KEY_OPTIONS}, - {SDLK_ESCAPE, FALSE, 0x1B, 0x1B, 0x1B, ALT_ESC}, - {SDLK_KP_ENTER,TRUE, PADENTER, PADENTER, CTL_PADENTER,ALT_PADENTER}, - {SDLK_KP_PLUS, TRUE, PADPLUS, '+', CTL_PADPLUS, ALT_PADPLUS}, - {SDLK_KP_MINUS,TRUE, PADMINUS, '-', CTL_PADMINUS,ALT_PADMINUS}, - {SDLK_KP_MULTIPLY,TRUE,PADSTAR, '*', CTL_PADSTAR, ALT_PADSTAR}, - {SDLK_KP_DIVIDE,TRUE, PADSLASH, '/', CTL_PADSLASH,ALT_PADSLASH}, - {SDLK_KP_PERIOD,TRUE, PADSTOP, '.', CTL_PADSTOP, ALT_PADSTOP}, - {SDLK_KP_0, TRUE, PAD0, '0', CTL_PAD0, ALT_PAD0}, - {SDLK_KP_1, TRUE, KEY_C1, '1', CTL_PAD1, ALT_PAD1}, - {SDLK_KP_2, TRUE, KEY_C2, '2', CTL_PAD2, ALT_PAD2}, - {SDLK_KP_3, TRUE, KEY_C3, '3', CTL_PAD3, ALT_PAD3}, - {SDLK_KP_4, TRUE, KEY_B1, '4', CTL_PAD4, ALT_PAD4}, - {SDLK_KP_5, TRUE, KEY_B2, '5', CTL_PAD5, ALT_PAD5}, - {SDLK_KP_6, TRUE, KEY_B3, '6', CTL_PAD6, ALT_PAD6}, - {SDLK_KP_7, TRUE, KEY_A1, '7', CTL_PAD7, ALT_PAD7}, - {SDLK_KP_8, TRUE, KEY_A2, '8', CTL_PAD8, ALT_PAD8}, - {SDLK_KP_9, TRUE, KEY_A3, '9', CTL_PAD9, ALT_PAD9}, - {0, 0, 0, 0, 0, 0} +/* keycode keypad normal shifted control alt*/ + {SDLK_LEFT, FALSE, KEY_LEFT, KEY_SLEFT, CTL_LEFT, ALT_LEFT}, + {SDLK_RIGHT, FALSE, KEY_RIGHT, KEY_SRIGHT, CTL_RIGHT, ALT_RIGHT}, + {SDLK_UP, FALSE, KEY_UP, KEY_SUP, CTL_UP, ALT_UP}, + {SDLK_DOWN, FALSE, KEY_DOWN, KEY_SDOWN, CTL_DOWN, ALT_DOWN}, + {SDLK_HOME, FALSE, KEY_HOME, KEY_SHOME, CTL_HOME, ALT_HOME}, + {SDLK_END, FALSE, KEY_END, KEY_SEND, CTL_END, ALT_END}, + {SDLK_PAGEUP, FALSE, KEY_PPAGE, KEY_SPREVIOUS, CTL_PGUP, ALT_PGUP}, + {SDLK_PAGEDOWN, FALSE, KEY_NPAGE, KEY_SNEXT, CTL_PGDN, ALT_PGDN}, + {SDLK_INSERT, FALSE, KEY_IC, KEY_SIC, CTL_INS, ALT_INS}, + {SDLK_DELETE, FALSE, KEY_DC, KEY_SDC, CTL_DEL, ALT_DEL}, + {SDLK_F1, FALSE, KEY_F(1), KEY_F(13), KEY_F(25), KEY_F(37)}, + {SDLK_F2, FALSE, KEY_F(2), KEY_F(14), KEY_F(26), KEY_F(38)}, + {SDLK_F3, FALSE, KEY_F(3), KEY_F(15), KEY_F(27), KEY_F(39)}, + {SDLK_F4, FALSE, KEY_F(4), KEY_F(16), KEY_F(28), KEY_F(40)}, + {SDLK_F5, FALSE, KEY_F(5), KEY_F(17), KEY_F(29), KEY_F(41)}, + {SDLK_F6, FALSE, KEY_F(6), KEY_F(18), KEY_F(30), KEY_F(42)}, + {SDLK_F7, FALSE, KEY_F(7), KEY_F(19), KEY_F(31), KEY_F(43)}, + {SDLK_F8, FALSE, KEY_F(8), KEY_F(20), KEY_F(32), KEY_F(44)}, + {SDLK_F9, FALSE, KEY_F(9), KEY_F(21), KEY_F(33), KEY_F(45)}, + {SDLK_F10, FALSE, KEY_F(10), KEY_F(22), KEY_F(34), KEY_F(46)}, + {SDLK_F11, FALSE, KEY_F(11), KEY_F(23), KEY_F(35), KEY_F(47)}, + {SDLK_F12, FALSE, KEY_F(12), KEY_F(24), KEY_F(36), KEY_F(48)}, + {SDLK_F13, FALSE, KEY_F(13), KEY_F(25), KEY_F(37), KEY_F(49)}, + {SDLK_F14, FALSE, KEY_F(14), KEY_F(26), KEY_F(38), KEY_F(50)}, + {SDLK_F15, FALSE, KEY_F(15), KEY_F(27), KEY_F(39), KEY_F(51)}, + {SDLK_BACKSPACE, FALSE, 0x08, 0x08, CTL_BKSP, ALT_BKSP}, + {SDLK_TAB, FALSE, 0x09, KEY_BTAB, CTL_TAB, ALT_TAB}, + {SDLK_PRINTSCREEN, FALSE, KEY_PRINT, KEY_SPRINT, KEY_PRINT, KEY_PRINT}, + {SDLK_PAUSE, FALSE, KEY_SUSPEND, KEY_SSUSPEND, KEY_SUSPEND, KEY_SUSPEND}, + {SDLK_CLEAR, FALSE, KEY_CLEAR, KEY_CLEAR, KEY_CLEAR, KEY_CLEAR}, + {SDLK_PAUSE, FALSE, KEY_BREAK, KEY_BREAK, KEY_BREAK, KEY_BREAK}, + {SDLK_HELP, FALSE, KEY_HELP, KEY_SHELP, KEY_LHELP, KEY_HELP}, + {SDLK_MENU, FALSE, KEY_OPTIONS, KEY_SOPTIONS, KEY_OPTIONS, KEY_OPTIONS}, + {SDLK_ESCAPE, FALSE, 0x1B, 0x1B, 0x1B, ALT_ESC}, + {SDLK_KP_ENTER, TRUE, PADENTER, PADENTER, CTL_PADENTER, ALT_PADENTER}, + {SDLK_KP_PLUS, TRUE, PADPLUS, '+', CTL_PADPLUS, ALT_PADPLUS}, + {SDLK_KP_MINUS, TRUE, PADMINUS, '-', CTL_PADMINUS, ALT_PADMINUS}, + {SDLK_KP_MULTIPLY, TRUE, PADSTAR, '*', CTL_PADSTAR, ALT_PADSTAR}, + {SDLK_KP_DIVIDE, TRUE, PADSLASH, '/', CTL_PADSLASH, ALT_PADSLASH}, + {SDLK_KP_PERIOD, TRUE, PADSTOP, '.', CTL_PADSTOP, ALT_PADSTOP}, + {SDLK_KP_0, TRUE, PAD0, '0', CTL_PAD0, ALT_PAD0}, + {SDLK_KP_1, TRUE, KEY_C1, '1', CTL_PAD1, ALT_PAD1}, + {SDLK_KP_2, TRUE, KEY_C2, '2', CTL_PAD2, ALT_PAD2}, + {SDLK_KP_3, TRUE, KEY_C3, '3', CTL_PAD3, ALT_PAD3}, + {SDLK_KP_4, TRUE, KEY_B1, '4', CTL_PAD4, ALT_PAD4}, + {SDLK_KP_5, TRUE, KEY_B2, '5', CTL_PAD5, ALT_PAD5}, + {SDLK_KP_6, TRUE, KEY_B3, '6', CTL_PAD6, ALT_PAD6}, + {SDLK_KP_7, TRUE, KEY_A1, '7', CTL_PAD7, ALT_PAD7}, + {SDLK_KP_8, TRUE, KEY_A2, '8', CTL_PAD8, ALT_PAD8}, + {SDLK_KP_9, TRUE, KEY_A3, '9', CTL_PAD9, ALT_PAD9}, + {0, 0, 0, 0, 0, 0} }; unsigned long PDC_get_input_fd(void) @@ -111,7 +111,7 @@ 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 + /* if we have an event, or 30 ms have passed without a screen update, or the timer has wrapped, update now */ if (haveevent || @@ -121,26 +121,26 @@ bool PDC_check_key(void) return haveevent; } -long PDC_atol (char *buffer, int radix) +long PDC_atol(char *buffer, int radix) { - unsigned long val = 0; - unsigned long tmp; - char *ptr; - - for (ptr = buffer; *ptr != '\0'; ptr++) - { - tmp = *ptr - '0'; - if (radix > 10) - if (tmp > 9) - tmp = *ptr - 'a' + 10; - if (tmp <= radix) - { - val += tmp; - if (ptr[1] != '\0') - val *= radix; - } - } - return (val); + unsigned long val = 0; + unsigned long tmp; + char *ptr; + + for (ptr = buffer; *ptr != '\0'; ptr++) + { + tmp = *ptr - '0'; + if (radix > 10) + if (tmp > 9) + tmp = *ptr - 'a' + 10; + if (tmp <= radix) + { + val += tmp; + if (ptr[1] != '\0') + val *= radix; + } + } + return val; } @@ -160,22 +160,22 @@ static int _process_key_event(void) { #ifdef PDC_WIDE if (unikey >= 0) - if ((event.key.keysym.sym == SDLK_LALT) || (event.key.keysym.sym == SDLK_RALT)) - { - if ((unikeyhex != 0) && (unikey != 0)) - { + if ((event.key.keysym.sym == SDLK_LALT) || (event.key.keysym.sym == SDLK_RALT)) + { + if ((unikeyhex != 0) && (unikey != 0)) + { unikeyval[unikey] = '\0'; - key = (int) PDC_atol (unikeyval, unikeyhex); - memset (unikeyval, '\0', 7); + key = (int) PDC_atol(unikeyval, unikeyhex); + memset(unikeyval, '\0', 7); unikeyhex = 0; unikey = -1; if (key != 0) - return (key); - } - else + return key; + } + else unikey = -1; - } -#endif + } +#endif if (SP->return_key_modifiers && event.key.keysym.sym == oldkey) { switch (oldkey) @@ -202,14 +202,14 @@ static int _process_key_event(void) #ifdef PDC_WIDE else { - if (event.type == SDL_KEYDOWN) - { - if ((event.key.keysym.sym == SDLK_LALT) || (event.key.keysym.sym == SDLK_RALT)) - { - if (unikey < 0) - unikey = 0; - } - } + if (event.type == SDL_KEYDOWN) + { + if ((event.key.keysym.sym == SDLK_LALT) || (event.key.keysym.sym == SDLK_RALT)) + { + if (unikey < 0) + unikey = 0; + } + } } #endif @@ -247,11 +247,11 @@ static int _process_key_event(void) { key = key_table[i].alt; } - - /* To get here, we ignore all other modifiers */ - else + { + /* To get here, we ignore all other modifiers */ key = key_table[i].normal; + } SP->key_code = (key > 0x100); break; @@ -260,59 +260,59 @@ static int _process_key_event(void) #ifdef PDC_WIDE if (unikey >= 0) - { - if (event.key.keysym.mod & KMOD_ALT) - { - if (unikeyhex != 0) - { - if (unikey < 6) - { - if (key >= ALT_PAD0 && key <= ALT_PAD9) - { - unikeyval[unikey] = key - ALT_PAD0 + '0'; - unikey++; - return -1; - } - else if ((event.key.keysym.sym >= 'a' && event.key.keysym.sym <= 'f') || (event.key.keysym.sym >= '0' && event.key.keysym.sym <= '9')) - { - unikeyval[unikey] = key; - unikey++; - return -1; - } - else if ((event.key.keysym.sym != SDLK_LALT) || (event.key.keysym.sym != SDLK_RALT)) - { - unikeyhex = 0; - unikey = -1; - } - } - } - else if (unikey == 0) - { - if (event.key.keysym.sym == SDLK_KP_PLUS) + { + if (event.key.keysym.mod & KMOD_ALT) + { + if (unikeyhex != 0) { - unikeyhex = 16; - return -1; - } - else if (event.key.keysym.sym == SDLK_KP_0) - { - unikeyhex = 10; - return -1; + if (unikey < 6) + { + if (key >= ALT_PAD0 && key <= ALT_PAD9) + { + unikeyval[unikey] = key - ALT_PAD0 + '0'; + unikey++; + return -1; + } + else if ((event.key.keysym.sym >= 'a' && event.key.keysym.sym <= 'f') || (event.key.keysym.sym >= '0' && event.key.keysym.sym <= '9')) + { + unikeyval[unikey] = key; + unikey++; + return -1; + } + else if ((event.key.keysym.sym != SDLK_LALT) || (event.key.keysym.sym != SDLK_RALT)) + { + unikeyhex = 0; + unikey = -1; + } + } } - else if ((event.key.keysym.sym != SDLK_LALT) || (event.key.keysym.sym != SDLK_RALT)) + else if (unikey == 0) { - unikeyhex = 0; - unikey = -1; + if (event.key.keysym.sym == SDLK_KP_PLUS) + { + unikeyhex = 16; + return -1; + } + else if (event.key.keysym.sym == SDLK_KP_0) + { + unikeyhex = 10; + return -1; + } + else if ((event.key.keysym.sym != SDLK_LALT) || (event.key.keysym.sym != SDLK_RALT)) + { + unikeyhex = 0; + unikey = -1; + } } - } - } - } + } + } #endif if (!key) { key = (int) event.key.keysym.sym; if (key >= 'a' && key <= 'z') - if (event.key.keysym.mod & KMOD_SHIFT) - key = toupper (key); + if (event.key.keysym.mod & KMOD_SHIFT) + key = toupper(key); if (key > 0x7f) key = 0; @@ -446,31 +446,31 @@ int PDC_get_key(void) case SDL_QUIT: exit(1); case SDL_WINDOWEVENT: - switch (event.window.event) - { - case SDL_WINDOWEVENT_SIZE_CHANGED: - case SDL_WINDOWEVENT_RESIZED: - if (pdc_own_screen && - (event.window.data2 / pdc_fheight != LINES || - event.window.data1 / pdc_fwidth != COLS)) - { - pdc_sheight = event.window.data2; - pdc_swidth = event.window.data1; + switch (event.window.event) + { + case SDL_WINDOWEVENT_SIZE_CHANGED: + case SDL_WINDOWEVENT_RESIZED: + if (pdc_own_screen && + (event.window.data2 / pdc_fheight != LINES || + event.window.data1 / pdc_fwidth != COLS)) + { + pdc_sheight = event.window.data2; + pdc_swidth = event.window.data1; - if (!SP->resized) - { - SP->resized = TRUE; - return KEY_RESIZE; - } - } - break; - case SDL_WINDOWEVENT_RESTORED: - case SDL_WINDOWEVENT_EXPOSED: + if (!SP->resized) + { + SP->resized = TRUE; + return KEY_RESIZE; + } + } + break; + case SDL_WINDOWEVENT_RESTORED: + case SDL_WINDOWEVENT_EXPOSED: SDL_RenderPresent(pdc_render); /* SDL_UpdateWindowSurface(pdc_window); */ - break; - } - break; + break; + } + break; case SDL_MOUSEMOTION: SDL_ShowCursor(SDL_ENABLE); case SDL_MOUSEBUTTONUP: diff --git a/sdl2/pdcscrn.c b/sdl2/pdcscrn.c index a3ac1597..ad711de6 100644 --- a/sdl2/pdcscrn.c +++ b/sdl2/pdcscrn.c @@ -11,19 +11,20 @@ RCSID("$Id: pdcscrn.c,v 1.34 2008/07/14 04:24:52 wmcbrine Exp $") SDL_Window *pdc_window = NULL; SDL_Renderer *pdc_render = NULL; SDL_Texture *pdc_texture = NULL; +SDL_Surface *pdc_screen = NULL, *pdc_font = NULL, *pdc_icon = NULL, + *pdc_back = NULL, *pdc_tileback = NULL; +int pdc_sheight = 0, pdc_swidth = 0, pdc_yoffset = 0, pdc_xoffset = 0; + #ifdef PDC_WIDE -#ifndef PDC_FONT_PATH -#define PDC_FONT_PATH "/usr/local/share/fonts/truetype/dejavu/DejaVuSansMono.ttf" -#endif +# ifndef PDC_FONT_PATH +# define PDC_FONT_PATH "/usr/local/share/fonts/truetype/dejavu/DejaVuSansMono.ttf" +# endif TTF_Font *pdc_ttffont = NULL; SDL_Color *pdc_ttffont_foregroundcolor = NULL; SDL_Color *pdc_ttffont_backgroundcolor = NULL; int pdc_ttffont_spointsz = 12; int pdc_ttffont_hint = TTF_HINTING_MONO; #endif -SDL_Surface *pdc_screen = NULL, *pdc_font = NULL, *pdc_icon = NULL, - *pdc_back = NULL, *pdc_tileback = NULL; -int pdc_sheight = 0, pdc_swidth = 0, pdc_yoffset = 0, pdc_xoffset = 0; SDL_Color pdc_color[16]; Uint32 pdc_mapped[16]; @@ -35,13 +36,13 @@ bool pdc_own_screen; static struct {short f, b;} atrtab[PDC_COLOR_PAIRS]; #ifdef PDC_WIDE -void PDC_clean (void) +void PDC_clean(void) { if (pdc_ttffont) { - TTF_CloseFont (pdc_ttffont); + TTF_CloseFont(pdc_ttffont); pdc_ttffont = NULL; - TTF_Quit (); + TTF_Quit(); } if (pdc_tileback != NULL) { @@ -61,7 +62,7 @@ void PDC_clean (void) if (pdc_font != NULL) { SDL_FreeSurface(pdc_font); - pdc_font = NULL; + pdc_font = NULL; } if (pdc_texture != NULL) { @@ -75,25 +76,25 @@ void PDC_clean (void) } if (pdc_window != NULL) { - SDL_DestroyWindow (pdc_window); - pdc_window = NULL; + SDL_DestroyWindow(pdc_window); + pdc_window = NULL; } - SDL_Quit (); + SDL_Quit(); } #endif void PDC_retile(void) -{ - Uint32 pixel_format; +{ + Uint32 pixel_format; if (pdc_tileback) SDL_FreeSurface(pdc_tileback); pixel_format = SDL_GetWindowPixelFormat(pdc_window); if (pixel_format == SDL_PIXELFORMAT_UNKNOWN) - return; + return; pdc_tileback = SDL_ConvertSurfaceFormat(pdc_screen, pixel_format, 0); if (pdc_tileback == NULL) - return; + return; if (pdc_back) { @@ -146,7 +147,7 @@ int PDC_scr_open(int argc, char **argv) if (pdc_own_screen) { - if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_EVENTS) < 0) + if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_EVENTS) < 0) { fprintf(stderr, "Could not start SDL: %s\n", SDL_GetError()); return ERR; @@ -154,24 +155,24 @@ int PDC_scr_open(int argc, char **argv) #ifdef PDC_WIDE atexit(PDC_clean); -#else +#else atexit(SDL_Quit); -#endif +#endif } #ifdef PDC_WIDE if (!pdc_ttffont) { - if (TTF_Init () == -1) + if (TTF_Init() == -1) { fprintf(stderr, "Could not start SDL_TTF: %s\n", SDL_GetError()); return ERR; } - const char *ptsz = getenv ("PDC_FONT_POINT_SIZE"); + const char *ptsz = getenv("PDC_FONT_POINT_SIZE"); if (ptsz != NULL) - pdc_ttffont_spointsz = atoi (ptsz); + pdc_ttffont_spointsz = atoi(ptsz); if (pdc_ttffont_spointsz <= 0) - pdc_ttffont_spointsz = 12; + pdc_ttffont_spointsz = 12; const char *fname = getenv("PDC_FONT"); pdc_ttffont = TTF_OpenFont(fname ? fname : PDC_FONT_PATH, pdc_ttffont_spointsz); TTF_SetFontKerning (pdc_ttffont, 0); @@ -184,8 +185,8 @@ int PDC_scr_open(int argc, char **argv) return ERR; } - SP->mono = FALSE; -#else + SP->mono = FALSE; +#else if (!pdc_font) { const char *fname = getenv("PDC_FONT"); @@ -202,7 +203,7 @@ int PDC_scr_open(int argc, char **argv) } SP->mono = !pdc_font->format->palette; -#endif +#endif if (!SP->mono && !pdc_back) { @@ -221,13 +222,13 @@ int PDC_scr_open(int argc, char **argv) #ifdef PDC_WIDE TTF_SizeText(pdc_ttffont, "W", &pdc_fwidth, &pdc_fheight); -#else +#else pdc_fheight = pdc_font->h / 8; pdc_fwidth = pdc_font->w / 32; if (!SP->mono) pdc_flastc = pdc_font->format->palette->ncolors - 1; -#endif +#endif if (pdc_own_screen && !pdc_icon) { @@ -249,29 +250,29 @@ int PDC_scr_open(int argc, char **argv) pdc_window = SDL_CreateWindow((argc ? argv[0] : "PDCurses"), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, pdc_swidth, pdc_sheight, SDL_WINDOW_RESIZABLE); if (pdc_window == NULL) - { - fprintf(stderr, "Could not open SDL window: %s\n", SDL_GetError()); - return ERR; - } + { + fprintf(stderr, "Could not open SDL window: %s\n", SDL_GetError()); + return ERR; + } SDL_SetWindowIcon(pdc_window, pdc_icon); - pdc_screen = SDL_GetWindowSurface(pdc_window); + pdc_screen = SDL_GetWindowSurface(pdc_window); if (pdc_screen == NULL) - { - fprintf(stderr, "Could not open SDL window surface: %s\n", SDL_GetError()); - return ERR; - } + { + fprintf(stderr, "Could not open SDL window surface: %s\n", SDL_GetError()); + return ERR; + } pdc_render = SDL_CreateRenderer(pdc_window, -1, 0); if (pdc_render == NULL) - { + { fprintf(stderr, "Could not open SDL window renderer: %s\n", SDL_GetError()); return ERR; - } + } pdc_texture = SDL_CreateTexture(pdc_render, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, pdc_swidth, pdc_sheight); if (pdc_texture == NULL) - { + { fprintf(stderr, "Could not open SDL texture: %s\n", SDL_GetError()); return ERR; - } + } } else { diff --git a/sdl2/pdcsdl.h b/sdl2/pdcsdl.h index fe6813cc..17587b23 100644 --- a/sdl2/pdcsdl.h +++ b/sdl2/pdcsdl.h @@ -10,6 +10,9 @@ PDCEX SDL_Window *pdc_window; PDCEX SDL_Renderer *pdc_render; PDCEX SDL_Texture *pdc_texture; +PDCEX SDL_Surface *pdc_screen, *pdc_font, *pdc_icon, *pdc_back; +PDCEX int pdc_sheight, pdc_swidth, pdc_yoffset, pdc_xoffset; + #ifdef PDC_WIDE PDCEX TTF_Font *pdc_ttffont; PDCEX SDL_Color *pdc_ttffont_foregroundcolor; @@ -17,8 +20,6 @@ PDCEX SDL_Color *pdc_ttffont_backgroundcolor; PDCEX int pdc_ttffont_spointsz; PDCEX int pdc_ttffont_hint; #endif -PDCEX SDL_Surface *pdc_screen, *pdc_font, *pdc_icon, *pdc_back; -PDCEX int pdc_sheight, pdc_swidth, pdc_yoffset, pdc_xoffset; extern SDL_Surface *pdc_tileback; /* used to regenerate the background of "transparent" cells */ diff --git a/sdl2/pdcsetsc.c b/sdl2/pdcsetsc.c index 49abce7e..ecfb17a3 100644 --- a/sdl2/pdcsetsc.c +++ b/sdl2/pdcsetsc.c @@ -16,9 +16,9 @@ RCSID("$Id: pdcsetsc.c,v 1.7 2008/07/14 04:24:52 wmcbrine Exp $") PDC_set_blink() toggles whether the A_BLINK attribute sets an actual blink mode (TRUE), or sets the background color to high intensity (FALSE). The default is platform-dependent (FALSE in - most cases). It returns OK if it could set the state to match - the given parameter, ERR otherwise. Current platforms also - adjust the value of COLORS according to this function -- 16 for + most cases). It returns OK if it could set the state to match + the given parameter, ERR otherwise. Current platforms also + adjust the value of COLORS according to this function -- 16 for FALSE, and 8 for TRUE. PDC_set_title() sets the title of the window in which the curses diff --git a/sdl2/sdltest.c b/sdl2/sdltest.c index 40257f06..f9673c44 100644 --- a/sdl2/sdltest.c +++ b/sdl2/sdltest.c @@ -10,7 +10,7 @@ #include #include -/* You could #include pdcsdl.h, or just add the relevant declarations +/* You could #include pdcsdl.h, or just add the relevant declarations here: */ PDCEX SDL_Window *pdc_window; @@ -33,7 +33,7 @@ int main(int argc, char **argv) atexit(SDL_Quit); pdc_window = SDL_CreateWindow("PDCurses for SDL", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, 0); - pdc_screen = SDL_GetWindowSurface(pdc_window); + pdc_screen = SDL_GetWindowSurface(pdc_window); /* Initialize PDCurses */ @@ -56,7 +56,7 @@ int main(int argc, char **argv) dest.w = i; dest.h = j; - SDL_FillRect(pdc_screen, &dest, + SDL_FillRect(pdc_screen, &dest, SDL_MapRGB(pdc_screen->format, rand() % 256, rand() % 256, rand() % 256)); }