Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. PDCurses for SDL 1.x
  2. ====================
  3.  
  4. This is a port of PDCurses for version 1.x of SDL.
  5.  
  6.  
  7. Building
  8. --------
  9.  
  10. - On *nix (including Linux), run "make" in the sdl1 directory. There is
  11.   no configure script (yet?) for this port. This assumes a working
  12.   sdl-config, and GNU make. It builds the library pdcurses.a (dynamic
  13.   lib not implemented).
  14.  
  15. - The makefile accepts the optional parameter "DEBUG=Y", and recognizes
  16.   the optional PDCURSES_SRCDIR environment variable, as with the console
  17.   ports. "WIDE=Y" builds a version that not only uses 16-bit Unicode
  18.   characters, but depends on the SDL_ttf library, instead of using
  19.   simple bitmap fonts. "UTF8=Y" makes PDCurses ignore the system locale,
  20.   and treat all narrow-character strings as UTF-8; this option has no
  21.   effect unless WIDE=Y is also set. Add the target "demos" to build the
  22.   sample programs.
  23.  
  24.  
  25. Usage
  26. -----
  27.  
  28. There are no special requirements to use PDCurses for SDL -- all
  29. PDCurses-compatible code should work fine. Nothing extra is needed
  30. beyond the base SDL library. However, there are some optional special
  31. features, described here.
  32.  
  33. The SDL ports operate in one of two ways, depending on whether or not
  34. they were built with WIDE=Y:
  35.  
  36.  
  37. ### 8-bit mode
  38.  
  39. The font is a simple BMP, 32 characters wide by 8 characters tall,
  40. preferably with a palette. (BMPs without palettes still work, but in
  41. that case, no attributes will be available, nor will the cursor work.)
  42. The first entry in the palette (usually black) is treated as the
  43. background color; the last entry (usually white) is treated as the
  44. foreground. These are changed or made transparent as appropriate; any
  45. other colors in the palette are passed through unchanged. So -- although
  46. a one-bit depth is sufficient for a normal font -- you could redraw some
  47. characters as multi-colored tiles.
  48.  
  49. The font must be monospaced. The size of each character is derived by
  50. dividing the width of the BMP by 32 and the height by 8. There is no
  51. constraint on the dimensions.
  52.  
  53. As provided in the default font and expected by acs_map[], the font is
  54. in Code Page 437 form. But you can of course use any layout if you're
  55. not relying on correct values for the ACS_* macros.
  56.  
  57. The font can be set via the environment variable PDC_FONT. If it's not
  58. set, PDCurses looks for a file named "pdcfont.bmp" in the current
  59. directory at the time of initscr(). If neither is found, it uses the
  60. built-in default font encoded in font437.h.
  61.  
  62.  
  63. ### 16-bit mode
  64.  
  65. Instead of a BMP, PDC_FONT points to a TrueType font. Only true
  66. monospaced fonts work well. The font can be set at compile time via
  67. PDC_FONT_PATH, and/or at runtime via pdc_ttffont. The environment
  68. variable PDC_FONT_SIZE is also available to control the font size (also
  69. as a compile-time define, and at runtime as pdc_font_size.) The
  70. character mapping for chtypes is 16-bit Unicode (the Basic Multilingual
  71. Plane).
  72.  
  73. The default font is: /usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf
  74.  
  75.  
  76. Backgrounds
  77. -----------
  78.  
  79. PDCurses for SDL supports an optional background image BMP. This is used
  80. whenever start_color() has not been called (see the ptest demo for an
  81. example), or when use_default_colors() has been called after
  82. start_color(), and the background color of a pair has been set to -1
  83. (see ozdemo, worm, and rain for examples). The usage parallels that of
  84. ncurses in an appropriate terminal (e.g., Gnome Terminal). The image is
  85. tiled to cover the PDCurses window, and can be any size or depth.
  86.  
  87. As with the font, you can point to a location for the background via the
  88. environment variable PDC_BACKGROUND; "pdcback.bmp" is the fallback.
  89. (There is no default background.)
  90.  
  91.  
  92. Icons
  93. -----
  94.  
  95. The icon (used with SDL_WM_SetIcon() -- not used for the executable
  96. file) can be set via the environment variable PDC_ICON, and falls back
  97. to "pdcicon.bmp", and then to the built-in icon from iconbmp.h. The
  98. built-in icon is the PDCurses logo, as seen in ../common/icon32.xpm.
  99.  
  100. If pdc_screen is preinitialized (see below), PDCurses does not attempt
  101. to set the icon.
  102.  
  103.  
  104. Screen size
  105. -----------
  106.  
  107. The default screen size is 80x25 characters (whatever size they may be),
  108. but you can override this via the environment variables PDC_COLS and/or
  109. PDC_LINES. If pdc_screen is preinitialized (see below), these are
  110. ignored.
  111.  
  112.  
  113. Integration with SDL
  114. --------------------
  115.  
  116. If you want to go further, you can mix PDCurses and SDL functions. (Of
  117. course this is extremely non-portable!) To aid you, there are several
  118. external variables and functions specific to the SDL ports; you could
  119. include pdcsdl.h, or just add the declarations you need in your code:
  120.  
  121.     PDCEX SDL_Surface *pdc_screen, *pdc_font, *pdc_icon, *pdc_back;
  122.     PDCEX int pdc_sheight, pdc_swidth, pdc_yoffset, pdc_xoffset;
  123.  
  124.     PDCEX void PDC_update_rects(void);
  125.     PDCEX void PDC_retile(void);
  126.  
  127. pdc_screen is the main surface, created by SDL_SetVideoMode(), unless
  128. it's preset before initscr(). (See sdltest.c for examples.) You can
  129. perform normal SDL operations on this surface, but PDCurses won't
  130. respect them when it updates. (For that, see PDC_retile().) As an
  131. alternative, you can preinitialize this surface before calling
  132. initscr(). In that case, you can use pdc_sheight, pdc_swidth,
  133. pdc_yoffset and/or pdc_xoffset (q.v.) to confine PDCurses to only a
  134. specific area of the surface, reserving the rest for other SDL
  135. operations. If you preinitialize pdc_screen, you'll have to close it
  136. yourself; PDCurses will ignore resize events, and won't try to set the
  137. icon. Also note that if you preinitialize pdc_screen, it need not be the
  138. display surface.
  139.  
  140. pdc_font (in 8-bit mode), pdc_icon, and pdc_back are the SDL_surfaces
  141. for the font, icon, and background, respectively. You can set any or all
  142. of them before initscr(), and thus override any of the other ways to set
  143. them. But note that pdc_icon will be ignored if pdc_screen is preset.
  144.  
  145. pdc_sheight and pdc_swidth are the dimensions of the area of pdc_screen
  146. to be used by PDCurses. You can preset them before initscr(); if either
  147. is not set, it defaults to the full screen size minus the x or y offset,
  148. as appropriate.
  149.  
  150. pdc_xoffset and pdc_yoffset are the x and y offset for the area of
  151. pdc_screen to be used by PDCurses. See the sdltest demo for an example.
  152.  
  153. PDC_retile() makes a copy of pdc_screen, then tiles it with the
  154. background image, if any. The resulting surface is used as the
  155. background for transparent character cells. PDC_retile() is called from
  156. initscr() and resize_term(). However, you can also use it at other
  157. times, to take advantage of the way it copies pdc_screen: Draw some SDL
  158. stuff; call PDC_retile(); do some curses stuff -- it will use whatever
  159. was on pdc_screen as the background. Then you can erase the curses
  160. screen, do some more SDL stuff, and call PDC_retile() again to make a
  161. new background. (If you don't erase the curses screen, it will be
  162. incorporated into the background when you call PDC_retile().) But this
  163. only works if no background image is set.
  164.  
  165.  
  166. Interaction with stdio
  167. ----------------------
  168.  
  169. As with X11, it's a bad idea to mix curses and stdio calls. (In fact,
  170. that's true for PDCurses on any platform; but especially these two,
  171. which don't run under terminals.) Depending on how SDL is built, stdout
  172. and stderr may be redirected to files.
  173.  
  174.  
  175. Distribution Status
  176. -------------------
  177.  
  178. The files in this directory are released to the public domain.
  179.  
  180.  
  181. Acknowledgements
  182. ----------------
  183.  
  184. Original SDL port was provided by William McBrine
  185. TTF support based on contributions by Laura Michaels
  186.