apps/graphics/pdcurs34: Add NuttX framebuffer color managment and beginning of some rendering logic.
This commit is contained in:
parent
65555542e5
commit
ad54b77f33
@ -84,6 +84,7 @@ int rain_main(int argc, char *argv[])
|
||||
int x, y, j, r, c, seed;
|
||||
static int xpos[5], ypos[5];
|
||||
|
||||
traceon();
|
||||
initscr();
|
||||
seed = time((time_t *) 0);
|
||||
srand(seed);
|
||||
|
@ -870,8 +870,8 @@ BUGS FIXED:
|
||||
XCurses (using Xinitscr() instead of the obsolete XCursesProgramName).
|
||||
|
||||
- The 16-bit chtype is a working option again (by removing #define
|
||||
CHTYPE_LONG from curses.h), except in XCurses. It's not recommended;
|
||||
but if your needs are limited, it still works.
|
||||
CONFIG_PDCURSES_CHTYPE_LONG from curses.h), except in XCurses. It's
|
||||
not recommended; but if your needs are limited, it still works.
|
||||
|
||||
- Reset screen size in resetty() under DOS, as in Win32 and OS/2.
|
||||
|
||||
|
@ -69,16 +69,16 @@
|
||||
#define _DLCHAR 0x15 /* Delete Line char (^U) */
|
||||
|
||||
#ifdef CONFIG_PDCURSES_DEBUG
|
||||
# define PDC_LOG(x) if (pdc_trace_on) PDC_debug x
|
||||
# define RCSID(x) static const char *rcsid = x;
|
||||
# define PDC_LOG(x) if (pdc_trace_on) PDC_debug x
|
||||
# define RCSID(x) static const char *rcsid = x;
|
||||
#else
|
||||
# define PDC_LOG(x)
|
||||
# define RCSID(x)
|
||||
# define PDC_LOG(x)
|
||||
# define RCSID(x)
|
||||
#endif
|
||||
|
||||
/* Internal macros for attributes */
|
||||
|
||||
#ifdef CHTYPE_LONG
|
||||
#ifdef CONFIG_PDCURSES_CHTYPE_LONG
|
||||
# define PDC_COLOR_PAIRS 256
|
||||
#else
|
||||
# define PDC_COLOR_PAIRS 32
|
||||
@ -110,8 +110,8 @@ extern "C"
|
||||
|
||||
typedef struct /* Structure for ripped off lines */
|
||||
{
|
||||
int line;
|
||||
int (*init)(WINDOW *, int);
|
||||
int line;
|
||||
int (*init)(WINDOW *, int);
|
||||
} RIPPEDOFFLINE;
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -50,74 +50,50 @@ config PDCURSES_FOUNT_6X12
|
||||
config PDCURSES_FOUNT_6X13
|
||||
bool "6x13"
|
||||
select NXFONT_X11_MISC_FIXED_6X13
|
||||
---help---
|
||||
Enables font ID FONTID_X11_MISC_FIXED_6X13 == 27.
|
||||
|
||||
config PDCURSES_FOUNT_6X13B
|
||||
bool "6x13 Bold"
|
||||
select NXFONT_X11_MISC_FIXED_6X13B
|
||||
---help---
|
||||
Enables font ID FONTID_X11_MISC_FIXED_6X13B == 28.
|
||||
Enables font ID FONTID_X11_MISC_FIXED_6X13 == 27 and
|
||||
bold font ID FONTID_X11_MISC_FIXED_6X13B == 28.
|
||||
|
||||
config PDCURSES_FOUNT_7X13
|
||||
bool "7x13"
|
||||
select NXFONT_X11_MISC_FIXED_7X13
|
||||
---help---
|
||||
Enables font ID FONTID_X11_MISC_FIXED_7X13 == 30.
|
||||
|
||||
config PDCURSES_FOUNT_7X13B
|
||||
bool "7x13 Bold"
|
||||
select NXFONT_X11_MISC_FIXED_7X13B
|
||||
---help---
|
||||
Enables font ID FONTID_X11_MISC_FIXED_7X13B == 31.
|
||||
Enables font ID FONTID_X11_MISC_FIXED_7X13 == 30 and
|
||||
bold font ID FONTID_X11_MISC_FIXED_7X13B == 31.
|
||||
|
||||
config PDCURSES_FOUNT_7X14
|
||||
bool "7x14"
|
||||
select NXFONT_X11_MISC_FIXED_7X14
|
||||
---help---
|
||||
Enables font ID FONTID_X11_MISC_FIXED_7X14 == 33.
|
||||
|
||||
config PDCURSES_FOUNT_7X14B
|
||||
bool "7x14 Bold"
|
||||
select NXFONT_X11_MISC_FIXED_7X14B
|
||||
---help---
|
||||
Enables font ID FONTID_X11_MISC_FIXED_7X14B == 34.
|
||||
Enables font ID FONTID_X11_MISC_FIXED_7X14 == 33 and
|
||||
bold font ID FONTID_X11_MISC_FIXED_7X14B == 34.
|
||||
|
||||
config PDCURSES_FOUNT_8X13
|
||||
bool "8x13"
|
||||
select NXFONT_X11_MISC_FIXED_8X13
|
||||
---help---
|
||||
Enables font ID FONTID_X11_MISC_FIXED_8X13 == 35.
|
||||
|
||||
config PDCURSES_FOUNT_8X13B
|
||||
bool "8x13 Bold"
|
||||
select NXFONT_X11_MISC_FIXED_8X13B
|
||||
---help---
|
||||
Enables font ID FONTID_X11_MISC_FIXED_8X13B == 36.
|
||||
Enables font ID FONTID_X11_MISC_FIXED_8X13 == 35 and
|
||||
bold font ID FONTID_X11_MISC_FIXED_8X13B == 36.
|
||||
|
||||
config PDCURSES_FOUNT_9X15
|
||||
bool "9x15"
|
||||
select NXFONT_X11_MISC_FIXED_9X15
|
||||
select NXFONT_X11_MISC_FIXED_9X15B
|
||||
---help---
|
||||
Enables font ID FONTID_X11_MISC_FIXED_9X15 == 38.
|
||||
|
||||
config PDCURSES_FOUNT_9X15B
|
||||
bool "9x15 Bold"
|
||||
select NXFONT_X11_MISC_FIXED_9x15B
|
||||
---help---
|
||||
Enables font ID FONTID_X11_MISC_FIXED_9X15B == 39.
|
||||
Enables font ID FONTID_X11_MISC_FIXED_9X15 == 38 and
|
||||
bold font ID FONTID_X11_MISC_FIXED_9X15B == 39.
|
||||
|
||||
config PDCURSES_FOUNT_9X18
|
||||
bool "9x18"
|
||||
select NXFONT_X11_MISC_FIXED_9X18
|
||||
---help---
|
||||
Enables font ID FONTID_X11_MISC_FIXED_9X18 == 40.
|
||||
|
||||
config PDCURSES_FOUNT_9X18B
|
||||
bool "9x18 Bold"
|
||||
select NXFONT_X11_MISC_FIXED_9X18B
|
||||
---help---
|
||||
Enables font ID FONTID_X11_MISC_FIXED_9X18B == 41.
|
||||
Enables font ID FONTID_X11_MISC_FIXED_9X18 == 40 and
|
||||
bold font ID FONTID_X11_MISC_FIXED_9X18B == 41.
|
||||
|
||||
config PDCURSES_FOUNT_10X20
|
||||
bool "10x20"
|
||||
|
@ -73,9 +73,9 @@ chtype acs_map[128];
|
||||
*
|
||||
* Description:
|
||||
* Move the physical cursor (as opposed to the logical cursor affected by
|
||||
* wmove()) to the given location. This is called mainly from doupdate().
|
||||
* In general, this function need not compare the old location with the new
|
||||
* one, and should just move the cursor unconditionally.
|
||||
* wmove()) to the given location. T his is called mainly from doupdate().
|
||||
* In general, this function need not compare the old location with the
|
||||
* new one, and should just move the cursor unconditionally.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -83,17 +83,46 @@ chtype acs_map[128];
|
||||
|
||||
void PDC_gotoyx(int row, int col)
|
||||
{
|
||||
chtype ch;
|
||||
int oldrow;
|
||||
int oldcol;
|
||||
|
||||
PDC_LOG(("PDC_gotoyx() - called: row %d col %d\n", row, col));
|
||||
#warning Missing logic
|
||||
|
||||
if (SP->mono)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* Clear the old cursor */
|
||||
|
||||
oldrow = SP->cursrow;
|
||||
oldcol = SP->curscol;
|
||||
|
||||
PDC_transform_line(oldrow, oldcol, 1, curscr->_y[oldrow] + oldcol);
|
||||
|
||||
if (SP->visibility == 0)
|
||||
{
|
||||
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;
|
||||
|
||||
PDC_transform_line(row, col, 1, &ch);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: PDC_transform_line
|
||||
*
|
||||
* Description:
|
||||
* The core output routine. It takes len chtype entities from srcp (a
|
||||
* The core output routine. It takes len chtype entities from srcp (a
|
||||
* pointer into curscr) and renders them to the physical screen at line
|
||||
* lineno, column x. It must also translate characters 0-127 via acs_map[],
|
||||
* lineno, column x. It must also translate characters 0-127 via acs_map[],
|
||||
* if they're flagged with A_ALTCHARSET in the attribute portion of the
|
||||
* chtype.
|
||||
*
|
||||
@ -101,6 +130,78 @@ void PDC_gotoyx(int row, int col)
|
||||
|
||||
void PDC_transform_line(int lineno, int x, int len, const chtype *srcp)
|
||||
{
|
||||
PDC_LOG(("PDC_transform_line() - called: line %d\n", lineno));
|
||||
FAR struct pdc_fbscreen_s *fbscreen = (FAR struct pdc_fbscreen_s *)SP;
|
||||
FAR struct pdc_fbstate_s *fbstate;
|
||||
chtype ch;
|
||||
short fg;
|
||||
short bg;
|
||||
bool bold;
|
||||
int i;
|
||||
|
||||
PDC_LOG(("PDC_transform_line() - called: lineno=%d x=%d len=%d\n",
|
||||
lineno, x, len));
|
||||
|
||||
DEBUGASSERT(fbscreen != NULL);
|
||||
fbstate = &fbscreen->fbstate;
|
||||
|
||||
/* Set up the start position for the transfer */
|
||||
#warning Missing logic
|
||||
|
||||
/* Add each character to the framebuffer at the current position,
|
||||
* incrementing the horizontal position after each character.
|
||||
*/
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
ch = srcp[i];
|
||||
|
||||
/* Get the forground and background colors of the font */
|
||||
|
||||
PDC_pair_content(PAIR_NUMBER(ch), &fg, &bg);
|
||||
|
||||
/* Handle attributes */
|
||||
|
||||
bold = false;
|
||||
if (!SP->mono)
|
||||
{
|
||||
/* REVISIT: Only bold and reverse attributed handled */
|
||||
/* Bold will select the bold font.
|
||||
*/
|
||||
|
||||
bold = ((ch & A_BOLD) != 0);
|
||||
|
||||
/* Swap the foreground and background colors if reversed */
|
||||
|
||||
if ((ch & A_REVERSE) != 0)
|
||||
{
|
||||
short tmp = fg;
|
||||
fg = bg;
|
||||
bg = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PDCURSESCHTYPE_LONG
|
||||
/* Translate characters 0-127 via acs_map[], if they're flagged with
|
||||
* A_ALTCHARSET in the attribute portion of the chtype.
|
||||
*/
|
||||
|
||||
if (ch & A_ALTCHARSET && !(ch & 0xff80))
|
||||
{
|
||||
ch = (ch & (A_ATTRIBUTES ^ A_ALTCHARSET)) | acs_map[ch & 0x7f];
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Rend the font glyph into the framebuffer */
|
||||
#warning Missing logic
|
||||
|
||||
/* Apply more attributes */
|
||||
|
||||
if ((ch & (A_UNDERLINE | A_LEFTLINE | A_RIGHTLINE)) != 0)
|
||||
{
|
||||
#warning Missing logic
|
||||
}
|
||||
|
||||
/* Increment the X position by the font width */
|
||||
#warning Missing logic
|
||||
}
|
||||
}
|
||||
|
@ -51,44 +51,53 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#undef HAVE_BOLD_FONT
|
||||
|
||||
#if defined(CONFIG_PDCURSES_FOUNT_4X6)
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_4X6
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_4X6
|
||||
# define PDCURSES_BOLD_FONTID FONTID_X11_MISC_FIXED_4X6
|
||||
#elif defined(CONFIG_PDCURSES_FOUNT_5X7)
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_5X7
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_5X7
|
||||
# define PDCURSES_BOLD_FONTID FONTID_X11_MISC_FIXED_5X7
|
||||
#elif defined(CONFIG_PDCURSES_FOUNT_5X8)
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_5X8
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_5X8
|
||||
# define PDCURSES_BOLD_FONTID FONTID_X11_MISC_FIXED_5X8
|
||||
#elif defined(CONFIG_PDCURSES_FOUNT_6X9)
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_6X9
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_6X9
|
||||
# define PDCURSES_BOLD_FONTID FONTID_X11_MISC_FIXED_6X9
|
||||
#elif defined(CONFIG_PDCURSES_FOUNT_6X10)
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_6X10
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_6X10
|
||||
# define PDCURSES_BOLD_FONTID FONTID_X11_MISC_FIXED_6X10
|
||||
#elif defined(CONFIG_PDCURSES_FOUNT_6X12)
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_6X12
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_6X12
|
||||
# define PDCURSES_BOLD_FONTID FONTID_X11_MISC_FIXED_6X12
|
||||
#elif defined(CONFIG_PDCURSES_FOUNT_6X13)
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_6X13
|
||||
#elif defined(CONFIG_PDCURSES_FOUNT_6X13B)
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_6X13B
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_6X13
|
||||
# define PDCURSES_BOLD_FONTID FONTID_X11_MISC_FIXED_6X13B
|
||||
# define HAVE_BOLD_FONT 1
|
||||
#elif defined(CONFIG_PDCURSES_FOUNT_7X13)
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_7X13
|
||||
#elif defined(CONFIG_PDCURSES_FOUNT_7X13B)
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_7X13B
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_7X13
|
||||
# define PDCURSES_BOLD_FONTID FONTID_X11_MISC_FIXED_7X13B
|
||||
# define HAVE_BOLD_FONT 1
|
||||
#elif defined(CONFIG_PDCURSES_FOUNT_7X14)
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_7X14
|
||||
#elif defined(CONFIG_PDCURSES_FOUNT_7X14B)
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_7X14B
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_7X14
|
||||
# define PDCURSES_BOLD_FONTID FONTID_X11_MISC_FIXED_7X14B
|
||||
# define HAVE_BOLD_FONT 1
|
||||
#elif defined(CONFIG_PDCURSES_FOUNT_8X13)
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_8X13
|
||||
#elif defined(CONFIG_PDCURSES_FOUNT_8X13B)
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_8X13B
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_8X13
|
||||
# define PDCURSES_BOLD_FONTID FONTID_X11_MISC_FIXED_8X13B
|
||||
# define HAVE_BOLD_FONT 1
|
||||
#elif defined(CONFIG_PDCURSES_FOUNT_9X15)
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_9X15
|
||||
#elif defined(CONFIG_PDCURSES_FOUNT_9X15B)
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_9X15B
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_9X15
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_9X15B
|
||||
# define HAVE_BOLD_FONT 1
|
||||
#elif defined(CONFIG_PDCURSES_FOUNT_9X18)
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_9X18
|
||||
#elif defined(CONFIG_PDCURSES_FOUNT_9X18B)
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_9X18B
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_9X18
|
||||
# define PDCURSES_BOLD_FONTID FONTID_X11_MISC_FIXED_9X18B
|
||||
# define HAVE_BOLD_FONT 1
|
||||
#elif defined(CONFIG_PDCURSES_FOUNT_10X20)
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_10X20
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_10X20
|
||||
# define PDCURSES_BOLD_FONTID FONTID_X11_MISC_FIXED_10X20
|
||||
#else
|
||||
# error No fixed width font selected
|
||||
#endif
|
||||
@ -105,6 +114,23 @@ extern "C"
|
||||
# define EXTERN extern
|
||||
#endif
|
||||
|
||||
/* Describes one color pair */
|
||||
|
||||
struct pdc_colorpair_s
|
||||
{
|
||||
short fg;
|
||||
short bg;
|
||||
};
|
||||
|
||||
/* Describes one RGB color */
|
||||
|
||||
struct pdc_rgbcolor_s
|
||||
{
|
||||
uint8_t red;
|
||||
uint8_t green;
|
||||
uint8_t blue;
|
||||
};
|
||||
|
||||
/* This structure provides the overall state of the frambuffer device */
|
||||
|
||||
struct pdc_fbstate_s
|
||||
@ -128,6 +154,25 @@ struct pdc_fbstate_s
|
||||
|
||||
uint8_t hoffset; /* Offset from left of display in pixels */
|
||||
uint8_t voffset; /* Offset from top of display in lines */
|
||||
|
||||
/* Cursor position in display rows x pixels */
|
||||
|
||||
struct nxgl_point_s curpos;
|
||||
|
||||
/* Colors */
|
||||
|
||||
struct pdc_colorpair_s colorpair[PDC_COLOR_PAIRS];
|
||||
struct pdc_rgbcolor_s rgbcolor[16];
|
||||
};
|
||||
|
||||
/* This structure contains the framebuffer device structure and is a cast
|
||||
* compatible with type SCREEN.
|
||||
*/
|
||||
|
||||
struct pdc_fbscreen_s
|
||||
{
|
||||
SCREEN screen;
|
||||
struct pdc_fbstate_s fbstate;
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -43,21 +43,11 @@
|
||||
#include <sys/mman.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "pdcnuttx.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/* This singleton represents the state of frame buffer device. pdcurses
|
||||
* depends on global variables and, hence, can never support more than a
|
||||
* single framebuffer instance in the same address space.
|
||||
*/
|
||||
|
||||
struct pdc_fbstate_s g_pdc_fbstate;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@ -77,7 +67,6 @@ struct pdc_fbstate_s g_pdc_fbstate;
|
||||
void PDC_scr_close(void)
|
||||
{
|
||||
PDC_LOG(("PDC_scr_close() - called\n"));
|
||||
#warning Missing logic
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -91,7 +80,15 @@ void PDC_scr_close(void)
|
||||
|
||||
void PDC_scr_free(void)
|
||||
{
|
||||
#warning Missing logic
|
||||
FAR struct pdc_fbscreen_s *fbscreen = (FAR struct pdc_fbscreen_s *)SP;
|
||||
FAR struct pdc_fbstate_s *fbstate;
|
||||
|
||||
DEBUGASSERT(fbscreen != NULL);
|
||||
fbstate = &fbscreen->fbstate;
|
||||
|
||||
close(fbstate->fd);
|
||||
free(fbscreen);
|
||||
SP = NULL;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -116,27 +113,31 @@ void PDC_scr_free(void)
|
||||
|
||||
int PDC_scr_open(int argc, char **argv)
|
||||
{
|
||||
FAR struct pdc_fbscreen_s *fbscreen;
|
||||
FAR const struct nx_font_s *fontset;
|
||||
FAR struct pdc_fbstate_s *fbstate;
|
||||
struct fb_videoinfo_s vinfo;
|
||||
struct fb_planeinfo_s pinfo;
|
||||
FAR const struct nx_font_s *fontset;
|
||||
uint32_t bitwidth;
|
||||
int ret;
|
||||
|
||||
PDC_LOG(("PDC_scr_open() - called\n"));
|
||||
|
||||
/* Allocate the global instance of SP */
|
||||
|
||||
SP = (SCREEN *)zalloc(sizeof(SCREEN));
|
||||
if (SP == NULL)
|
||||
fbscreen = (FAR struct pdc_fbscreen_s *)zalloc(sizeof(struct pdc_fbscreen_s));
|
||||
if (fbscreen == NULL)
|
||||
{
|
||||
PDC_LOG(("ERROR: Failed to allocate SP\n"));
|
||||
return ERR;
|
||||
}
|
||||
|
||||
SP = &fbscreen->screen;
|
||||
fbstate = &fbscreen->fbstate;
|
||||
|
||||
/* Open the framebuffer driver */
|
||||
|
||||
g_pdc_fbstate.fd = open(CONFIG_PDCURSES_FBDEV, O_RDWR);
|
||||
if (g_pdc_fbstate.fd < 0)
|
||||
fbstate->fd = open(CONFIG_PDCURSES_FBDEV, O_RDWR);
|
||||
if (fbstate->fd < 0)
|
||||
{
|
||||
PDC_LOG(("ERROR: Failed to open %s: %d\n",
|
||||
CONFIG_PDCURSES_FBDEV, errno));
|
||||
@ -145,7 +146,7 @@ int PDC_scr_open(int argc, char **argv)
|
||||
|
||||
/* Get the characteristics of the framebuffer */
|
||||
|
||||
ret = ioctl(g_pdc_fbstate.fd, FBIOGET_VIDEOINFO,
|
||||
ret = ioctl(fbstate->fd, FBIOGET_VIDEOINFO,
|
||||
(unsigned long)((uintptr_t)&vinfo));
|
||||
if (ret < 0)
|
||||
{
|
||||
@ -159,10 +160,10 @@ int PDC_scr_open(int argc, char **argv)
|
||||
PDC_LOG((" yres: %u\n", vinfo.yres));
|
||||
PDC_LOG((" nplanes: %u\n", vinfo.nplanes));
|
||||
|
||||
g_pdc_fbstate.xres = vinfo.xres; /* Horizontal resolution in pixel columns */
|
||||
g_pdc_fbstate.yres = vinfo.yres; /* Vertical resolution in pixel rows */
|
||||
fbstate->xres = vinfo.xres; /* Horizontal resolution in pixel columns */
|
||||
fbstate->yres = vinfo.yres; /* Vertical resolution in pixel rows */
|
||||
|
||||
ret = ioctl(g_pdc_fbstate.fd, FBIOGET_PLANEINFO,
|
||||
ret = ioctl(fbstate->fd, FBIOGET_PLANEINFO,
|
||||
(unsigned long)((uintptr_t)&pinfo));
|
||||
if (ret < 0)
|
||||
{
|
||||
@ -177,8 +178,8 @@ int PDC_scr_open(int argc, char **argv)
|
||||
PDC_LOG((" display: %u\n", pinfo.display));
|
||||
PDC_LOG((" bpp: %u\n", pinfo.bpp));
|
||||
|
||||
g_pdc_fbstate.stride = pinfo.stride; /* Length of a line in bytes */
|
||||
g_pdc_fbstate.bpp = pinfo.bpp; /* Bits per pixel */
|
||||
fbstate->stride = pinfo.stride; /* Length of a line in bytes */
|
||||
fbstate->bpp = pinfo.bpp; /* Bits per pixel */
|
||||
|
||||
/* Only these pixel depths are supported. vinfo.fmt is ignored, only
|
||||
* certain color formats are supported.
|
||||
@ -200,20 +201,20 @@ int PDC_scr_open(int argc, char **argv)
|
||||
* address mapping to make the memory accessible to the application.
|
||||
*/
|
||||
|
||||
g_pdc_fbstate.fbmem = mmap(NULL, pinfo.fblen, PROT_READ|PROT_WRITE,
|
||||
MAP_SHARED|MAP_FILE, g_pdc_fbstate.fd, 0);
|
||||
if (g_pdc_fbstate.fbmem == MAP_FAILED)
|
||||
fbstate->fbmem = mmap(NULL, pinfo.fblen, PROT_READ|PROT_WRITE,
|
||||
MAP_SHARED|MAP_FILE, fbstate->fd, 0);
|
||||
if (fbstate->fbmem == MAP_FAILED)
|
||||
{
|
||||
PDC_LOG(("ERROR: ioctl(FBIOGET_PLANEINFO) failed: %d\n", errno));
|
||||
goto errout_with_fd;
|
||||
}
|
||||
|
||||
PDC_LOG(("Mapped FB: %p\n", g_pdc_fbstate.fbmem));
|
||||
PDC_LOG(("Mapped FB: %p\n", fbstate->fbmem));
|
||||
|
||||
/* The the handle for the selected font */
|
||||
|
||||
g_pdc_fbstate.hfont = nxf_getfonthandle(PDCURSES_FONTID);
|
||||
if (g_pdc_fbstate.hfont == NULL)
|
||||
fbstate->hfont = nxf_getfonthandle(PDCURSES_FONTID);
|
||||
if (fbstate->hfont == NULL)
|
||||
{
|
||||
PDC_LOG(("ERROR: Failed to get font handle: %d\n", errno);)
|
||||
goto errout_with_fd;
|
||||
@ -221,7 +222,7 @@ int PDC_scr_open(int argc, char **argv)
|
||||
|
||||
/* Get information about the fontset */
|
||||
|
||||
fontset = nxf_getfontset(g_pdc_fbstate.hfont);
|
||||
fontset = nxf_getfontset(fbstate->hfont);
|
||||
if (fontset == NULL)
|
||||
{
|
||||
PDC_LOG(("ERROR: Failed to get font handle: %d\n", errno);)
|
||||
@ -234,24 +235,24 @@ int PDC_scr_open(int argc, char **argv)
|
||||
PDC_LOG((" mxbits: %u\n", fontset->mxbits));
|
||||
PDC_LOG((" spwidth: %u\n", fontset->spwidth));
|
||||
|
||||
g_pdc_fbstate.fheight = fontset->mxheight;
|
||||
g_pdc_fbstate.fwidth = fontset->mxwidth;
|
||||
fbstate->fheight = fontset->mxheight;
|
||||
fbstate->fwidth = fontset->mxwidth;
|
||||
|
||||
/* Calculate the drawable region */
|
||||
|
||||
SP->lines = g_pdc_fbstate.yres / g_pdc_fbstate.fheight;
|
||||
SP->cols = g_pdc_fbstate.xres / g_pdc_fbstate.fwidth;
|
||||
SP->lines = fbstate->yres / fbstate->fheight;
|
||||
SP->cols = fbstate->xres / fbstate->fwidth;
|
||||
|
||||
g_pdc_fbstate.hoffset = (g_pdc_fbstate.yres - g_pdc_fbstate.fheight * SP->lines) / 2;
|
||||
g_pdc_fbstate.hoffset = (g_pdc_fbstate.yres - g_pdc_fbstate.fheight * SP->lines) / 2;
|
||||
fbstate->hoffset = (fbstate->yres - fbstate->fheight * SP->lines) / 2;
|
||||
fbstate->hoffset = (fbstate->yres - fbstate->fheight * SP->lines) / 2;
|
||||
|
||||
return OK;
|
||||
|
||||
errout_with_font:
|
||||
|
||||
errout_with_fd:
|
||||
close(g_pdc_fbstate.fd);
|
||||
g_pdc_fbstate.fd = -1;
|
||||
close(fbstate->fd);
|
||||
fbstate->fd = -1;
|
||||
|
||||
errout_with_sp:
|
||||
free(SP);
|
||||
@ -263,11 +264,11 @@ errout_with_sp:
|
||||
* Name: PDC_resize_screen
|
||||
*
|
||||
* Description:
|
||||
* This does the main work of resize_term(). It may respond to non-zero
|
||||
* This does the main work of resize_term(). It may respond to non-zero
|
||||
* parameters, by setting the screen to the specified size; to zero
|
||||
* parameters, by setting the screen to a size chosen by the user at
|
||||
* runtime, in an unspecified way (e.g., by dragging the edges of the
|
||||
* window); or both. It may also do nothing, if there's no appropriate
|
||||
* window); or both. It may also do nothing, if there's no appropriate
|
||||
* action for the platform.
|
||||
*
|
||||
****************************************************************************/
|
||||
@ -285,7 +286,7 @@ int PDC_resize_screen(int nlines, int ncols)
|
||||
*
|
||||
* Description:
|
||||
* The non-portable functionality of reset_prog_mode() is handled here --
|
||||
* whatever's not done in _restore_mode(). In current ports: In OS/2, this
|
||||
* whatever's not done in _restore_mode(). In current ports: In OS/2, this
|
||||
* sets the keyboard to binary mode; in Win32, it enables or disables the
|
||||
* mouse pointer to match the saved mode; in others it does nothing.
|
||||
*
|
||||
@ -294,7 +295,6 @@ int PDC_resize_screen(int nlines, int ncols)
|
||||
void PDC_reset_prog_mode(void)
|
||||
{
|
||||
PDC_LOG(("PDC_reset_prog_mode() - called.\n"));
|
||||
#warning Missing logic
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -310,7 +310,6 @@ void PDC_reset_prog_mode(void)
|
||||
void PDC_reset_shell_mode(void)
|
||||
{
|
||||
PDC_LOG(("PDC_reset_shell_mode() - called.\n"));
|
||||
#warning Missing logic
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -318,13 +317,14 @@ void PDC_reset_shell_mode(void)
|
||||
*
|
||||
* Description:
|
||||
* Called from _restore_mode() in pdc_kernel.c, this function does the
|
||||
* actual mode changing, if applicable. Currently used only in DOS and OS/2.
|
||||
* actual mode changing, if applicable. Currently used only in DOS and
|
||||
* OS/2.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void PDC_restore_screen_mode(int i)
|
||||
{
|
||||
#warning Missing logic
|
||||
PDC_LOG(("PDC_restore_screen_mode(). i=%d.\n", i));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -332,45 +332,62 @@ void PDC_restore_screen_mode(int i)
|
||||
*
|
||||
* Description:
|
||||
* Called from _save_mode() in pdc_kernel.c, this function saves the actual
|
||||
* screen mode, if applicable. Currently used only in DOS and OS/2.
|
||||
* screen mode, if applicable. Currently used only in DOS and OS/2.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void PDC_save_screen_mode(int i)
|
||||
{
|
||||
#warning Missing logic
|
||||
PDC_LOG(("PDC_save_screen_mode(). i=%d.\n", i));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: PDC_init_pair
|
||||
*
|
||||
* Description:
|
||||
* The core of init_pair(). This does all the work of that function, except
|
||||
* checking for values out of range. The values passed to this function
|
||||
* The core of init_pair(). This does all the work of that function, except
|
||||
* checking for values out of range. The values passed to this function
|
||||
* should be returned by a call to PDC_pair_content() with the same pair
|
||||
* number. PDC_transform_line() should use the specified colors when
|
||||
* number. PDC_transform_line() should use the specified colors when
|
||||
* rendering a chtype with the given pair number.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void PDC_init_pair(short pair, short fg, short bg)
|
||||
{
|
||||
#warning Missing logic
|
||||
FAR struct pdc_fbscreen_s *fbscreen = (FAR struct pdc_fbscreen_s *)SP;
|
||||
FAR struct pdc_fbstate_s *fbstate;
|
||||
|
||||
PDC_LOG(("PDC_init_pair(). pair=%d, fg=%d, bg=%d\n", pair, fg, bg));
|
||||
|
||||
DEBUGASSERT(fbscreen != NULL);
|
||||
fbstate = &fbscreen->fbstate;
|
||||
|
||||
fbstate->colorpair[pair].fg = fg;
|
||||
fbstate->colorpair[pair].bg = bg;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: PDC_pair_content
|
||||
*
|
||||
* Description:
|
||||
* The core of pair_content(). This does all the work of that function,
|
||||
* The core of pair_content(). This does all the work of that function,
|
||||
* except checking for values out of range and null pointers.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int PDC_pair_content(short pair, short *fg, short *bg)
|
||||
{
|
||||
#warning Missing logic
|
||||
return ERR;
|
||||
FAR struct pdc_fbscreen_s *fbscreen = (FAR struct pdc_fbscreen_s *)SP;
|
||||
FAR struct pdc_fbstate_s *fbstate;
|
||||
|
||||
PDC_LOG(("PDC_pair_content(). pair=%d\n", pair));
|
||||
|
||||
DEBUGASSERT(fbscreen != NULL);
|
||||
fbstate = &fbscreen->fbstate;
|
||||
|
||||
*fg = fbstate->colorpair[pair].fg;
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -378,42 +395,64 @@ int PDC_pair_content(short pair, short *fg, short *bg)
|
||||
*
|
||||
* Description:
|
||||
* Returns true if init_color() and color_content() give meaningful
|
||||
* results, false otherwise. Called from can_change_color().
|
||||
* results, false otherwise. Called from can_change_color().
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
bool PDC_can_change_color(void)
|
||||
{
|
||||
#warning Missing logic
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: PDC_color_content
|
||||
*
|
||||
* Description:
|
||||
* The core of color_content(). This does all the work of that function,
|
||||
* The core of color_content(). This does all the work of that function,
|
||||
* except checking for values out of range and null pointers.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int PDC_color_content(short color, short *red, short *green, short *blue)
|
||||
{
|
||||
#warning Missing logic
|
||||
return ERR;
|
||||
FAR struct pdc_fbscreen_s *fbscreen = (FAR struct pdc_fbscreen_s *)SP;
|
||||
FAR struct pdc_fbstate_s *fbstate;
|
||||
|
||||
PDC_LOG(("PDC_init_color(). color=%d\n", color));
|
||||
|
||||
DEBUGASSERT(fbscreen != NULL);
|
||||
fbstate = &fbscreen->fbstate;
|
||||
|
||||
*red = DIVROUND(fbstate->rgbcolor[color].red * 1000, 255);
|
||||
*green = DIVROUND(fbstate->rgbcolor[color].green * 1000, 255);
|
||||
*blue = DIVROUND(fbstate->rgbcolor[color].blue * 1000, 255);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: PDC_init_color
|
||||
*
|
||||
* Description:
|
||||
* The core of init_color(). This does all the work of that function,
|
||||
* The core of init_color(). This does all the work of that function,
|
||||
* except checking for values out of range.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int PDC_init_color(short color, short red, short green, short blue)
|
||||
{
|
||||
#warning Missing logic
|
||||
return ERR;
|
||||
FAR struct pdc_fbscreen_s *fbscreen = (FAR struct pdc_fbscreen_s *)SP;
|
||||
FAR struct pdc_fbstate_s *fbstate;
|
||||
|
||||
PDC_LOG(("PDC_init_color(). color=%d, red=%d, green=%d, blue=%d\n",
|
||||
color, red, green, blue));
|
||||
|
||||
DEBUGASSERT(fbscreen != NULL);
|
||||
fbstate = &fbscreen->fbstate;
|
||||
|
||||
fbstate->rgbcolor[color].red = DIVROUND(red * 255, 1000);
|
||||
fbstate->rgbcolor[color].green = DIVROUND(green * 255, 1000);
|
||||
fbstate->rgbcolor[color].blue = DIVROUND(blue * 255, 1000);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
@ -37,6 +37,7 @@
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <poll.h>
|
||||
|
||||
#include "pdcnuttx.h"
|
||||
@ -49,10 +50,10 @@
|
||||
* Name: PDC_beep
|
||||
*
|
||||
* Description:
|
||||
* Emits a short audible beep. If this is not possible on your platform,
|
||||
* Emits a short audible beep. If this is not possible on your platform,
|
||||
* you must set SP->audible to false during initialization (i.e., from
|
||||
* PDC_scr_open() -- not here); otherwise, set it to true. This function is
|
||||
* called from beep().
|
||||
* PDC_scr_open() -- not here); otherwise, set it to true. This function
|
||||
* is called from beep().
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -66,10 +67,10 @@ void PDC_beep(void)
|
||||
* Name: PDC_napms
|
||||
*
|
||||
* Description:
|
||||
* This is the core delay routine, called by napms(). It pauses for about
|
||||
* (the X/Open spec says "at least") ms milliseconds, then returns. High
|
||||
* This is the core delay routine, called by napms(). It pauses for about
|
||||
* (the X/Open spec says "at least") ms milliseconds, then returns. High
|
||||
* degrees of accuracy and precision are not expected (though desirable, if
|
||||
* you can achieve them). More important is that this function gives back
|
||||
* you can achieve them). More important is that this function gives back
|
||||
* the process' time slice to the OS, so that PDCurses idles at low CPU
|
||||
* usage.
|
||||
*
|
||||
@ -78,7 +79,7 @@ void PDC_beep(void)
|
||||
void PDC_napms(int ms)
|
||||
{
|
||||
PDC_LOG(("PDC_napms() - called: ms=%d\n", ms));
|
||||
#warning Missing logic
|
||||
usleep(ms * 1000);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -13,6 +13,10 @@ config PDCURSES_FORCE_UTF8
|
||||
default n
|
||||
depends on PDCURSES_WIDE
|
||||
|
||||
config PDCURSES_CHTYPE_LONG
|
||||
bool "32-bit chtype"
|
||||
default n
|
||||
|
||||
config PDCURSES_DEBUG
|
||||
bool "Enable pdcurses debug ouput"
|
||||
default n
|
||||
|
@ -64,9 +64,9 @@
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdarg.h>
|
||||
#include <syslog.h>
|
||||
|
||||
#include "curspriv.h"
|
||||
|
||||
@ -83,33 +83,13 @@ bool pdc_trace_on = false;
|
||||
void PDC_debug(const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
FILE *dbfp;
|
||||
char hms[9];
|
||||
time_t now;
|
||||
|
||||
if (!pdc_trace_on)
|
||||
if (pdc_trace_on)
|
||||
{
|
||||
return;
|
||||
va_start(args, fmt);
|
||||
vsyslog(LOG_NOTICE, fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
/* Open debug log file append */
|
||||
|
||||
dbfp = fopen("trace", "a");
|
||||
if (!dbfp)
|
||||
{
|
||||
fprintf(stderr, "PDC_debug(): Unable to open debug log file\n");
|
||||
return;
|
||||
}
|
||||
|
||||
time(&now);
|
||||
strftime(hms, 9, "%H:%M:%S", localtime(&now));
|
||||
fprintf(dbfp, "At: %8.8ld - %s ", (long)clock(), hms);
|
||||
|
||||
va_start(args, fmt);
|
||||
vfprintf(dbfp, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
fclose(dbfp);
|
||||
}
|
||||
|
||||
void traceon(void)
|
||||
|
@ -237,7 +237,7 @@ WINDOW *PDC_makelines(WINDOW *win)
|
||||
int i;
|
||||
int j;
|
||||
|
||||
PDC_LOG(("PDC_makelines() - called: lines %d cols %d\n", nlines, ncols));
|
||||
PDC_LOG(("PDC_makelines() - called\n"));
|
||||
|
||||
if (!win)
|
||||
{
|
||||
@ -245,7 +245,7 @@ WINDOW *PDC_makelines(WINDOW *win)
|
||||
}
|
||||
|
||||
nlines = win->_maxy;
|
||||
ncols = win->_maxx;
|
||||
ncols = win->_maxx;
|
||||
|
||||
for (i = 0; i < nlines; i++)
|
||||
{
|
||||
|
@ -64,8 +64,6 @@
|
||||
****************************************************************************/
|
||||
|
||||
#define PDC_BUILD 3401
|
||||
#define PDCURSES 1 /* PDCurses-only routines */
|
||||
#define CHTYPE_LONG 1 /* size of chtype; long */
|
||||
|
||||
/* PDCurses Manifest Constants */
|
||||
|
||||
@ -188,8 +186,8 @@
|
||||
* and color into an unsigned char (all 8 bits!).
|
||||
*
|
||||
* Today, PDCurses by default uses a long (32 bits) for its chtype, as in
|
||||
* System V. The short chtype is still available, by undefining CHTYPE_LONG
|
||||
* and rebuilding the library.
|
||||
* System V. The short chtype is still available, by undefining
|
||||
* CONFIG_PDCURSES_CHTYPE_LONG and rebuilding the library.
|
||||
*
|
||||
* The following is the structure of a win->_attrs chtype:
|
||||
*
|
||||
@ -221,7 +219,7 @@
|
||||
|
||||
#define A_NORMAL (chtype)0
|
||||
|
||||
#ifdef CHTYPE_LONG
|
||||
#ifdef CONFIG_PDCURSES_CHTYPE_LONG
|
||||
# define A_ALTCHARSET (chtype)0x00010000
|
||||
# define A_RIGHTLINE (chtype)0x00020000
|
||||
# define A_LEFTLINE (chtype)0x00040000
|
||||
@ -297,7 +295,7 @@
|
||||
* available for A_ALTCHARSET
|
||||
*/
|
||||
|
||||
#ifdef CHTYPE_LONG
|
||||
#ifdef CONFIG_PDCURSES_CHTYPE_LONG
|
||||
# define ACS_PICK(w, n) ((chtype)w | A_ALTCHARSET)
|
||||
#else
|
||||
# define ACS_PICK(w, n) ((chtype)n)
|
||||
@ -740,10 +738,10 @@ extern "C"
|
||||
# define EXTERN extern
|
||||
#endif
|
||||
|
||||
#ifdef CHTYPE_LONG
|
||||
#ifdef CONFIG_PDCURSES_CHTYPE_LONG
|
||||
typedef uint32_t chtype; /* 16-bit attr + 16-bit char */
|
||||
#else
|
||||
typedef uint16_t chtype; /* 8-bit attr + 8-bit char */
|
||||
typedef uint16_t chtype; /* 8-bit attr + 8-bit char */
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PDCURSES_WIDE
|
||||
|
Loading…
Reference in New Issue
Block a user